Cannot set any option using setOption()
I initialize showdown object on the frontend side by doing something like
var converter = new showdown.Converter({'tables': true});
// some code ...
html = converter.makeHtml(markdownText);
If I print all options, I can see the tables is set to true.
{omitExtraWLInCodeBlocks: false, prefixHeaderId: false, tables: true}
However, it cannot interpret my table in md format, instead it only put it around a <p></p> For example
<p>| Tables | Are | Cool |
|---------- |:-------------: |------: |
| col 1 is | left-aligned | $1600 |
| col 2 is | centered | $12 |
| col 3 is | right-aligned | $1 |</p>
I've also tried to use converter.setOption('tables', true); or showdown.setOption('tables', true);, but neither of them worked.
I wonder if I set something wrong or I can only set options on the server (backend) side?
I found out that setOption() can be only used on the server side. However I used browserify to solve this problem. (Sorry, I don't know if I am allowed to put a link here, if not please tell me and I'll remove it)
Browserify allows you to "require" an object just like node.js. So on the top of my file, I simply putted
var showdown = require('showdown');
and then use browserify to compile the js file. It solved my issue.
if this is really happening, it seems like it's really a bug
ok since I am not a pro web developer, I will reopen this issue and leave the discussions/decisions to pros. But if anyone who encounters the same problem, please consider this solution as it solved mine pretty well.
I will look into it, but I've performed a quick test and couldn't reproduce the issue.
https://codepen.io/cshanejennings/pen/dLPJqg I don't see the inverse working here (attempting to convert html to markdown), but no idea if I'm doing something wrong, just started working with your library.
I should add I'm referencing the lib from the CDN here: https://cdn.jsdelivr.net/npm/[email protected]/dist/showdown.min.js
Just for a quick update, I'm currently looking at this issue.
Any updates on the issue?
I can't get tables working, too, in a web browser. I tried the following lines of code:
-
var converter = new showdown.Converter({tables: true}); -
var converter = new showdown.Converter({tables: "true"}); -
converter.setOption("tables", true); -
converter.setOption("tables", "true");
None of them works: I just get <p>|my|table|</p>
EDIT:
Looks like there's an issue with table parser.
This table works fine (and hence tables option):
| Header1 | Header2 |
|---|---|
| Value1 | Value2 |
I also am unable to set the option 'SimplifiedAutoLink' to true using
converter.setOption({SimplifiedAutoLink: true}),
I was researching on a way how to pass params to extensions. The setOption({}) does not work form me either. However here is one more way to approach it.