I'd like to print md table by using showdown.js. But, it doesn't seem to convert to markdown table correctly as I expected.
I tried setting options('table option') to be changed 'true' and converting text to md. but, doesn't work.
Below is the functions I implemented, for your information.
setMdConvert() <= As I said, I just tried all options for true.
getTechDescriptionMd() <= A test function for converting arbitary markdown text to markdown table
function setMdConvert() {
var mdConverter = new showdown.Converter();
var options = showdown.getOptions();
var keys = Object.keys(options);
keys.forEach((key) => {
if(options[key].constructor === boolConstructor)
mdConverter.setOption(key, true);
});
console.log(mdConverter.getOptions());
return mdConverter;
}
function getTechDescriptionMd() {
var text = '| h1 | h2 | h3 |' +
'|:------|:-------:|--------:|' +
'| 100 | [a][1] | ![b][2] |' +
'| *foo* | **bar** | ~~baz~~ |';
var html = mdConverter.makeHtml(text);
$('.desc-viewer').html(html);
}
result:
| h1 | h2 | h3 ||:------|:-------:|--------:|| 100 | [a][1] | ![b][2] || foo | bar | baz |
Is there any other option that I miss?
Here's a modified version of
.getTechDescriptionMd()that works for me. I added the linebreaks that I already mentioned in my comment from yesterday, plus I initializedmdConverterand set its option 'tables' to true (inspired by the documentation).It looks like this now:
The result I'm getting is: