Marked version: 0.3.19
Markdown flavor: GitHub Flavored Markdown
Github commit: b78deebf
When the table is indented (e.g. inside an unordered list), it's ignored.
The following markdown text doesn't work:
* Marked doesn't work with indented tables like this:
| column1 | column2 |
|---|---|
| value1 | value2 |
| value3 | value4 |
See it in the Marked Demo page
It should be rendered to:
Marked doesn't work with indented tables like this:
| column1 | column2 |
|---|---|
| value1 | value2 |
| value3 | value4 |
Basic usage.
var html = marked(example);
After a little of debug, I found the line where the table is ignored:
if (top && (cap = this.rules.table.exec(src))) {
As the table is nested in the list item, top === false, so the table syntax is not considered a table anymore.
In GFM a table can be defined in a non-top level (as demonstrated in my example), so... I think this can be a bug.
@wpomier looks like you are correct. Would you like to submit a PR removing the check for top on that line?
Also add a test in test/new/ to prevent regressions
Given this is not an example called out in a spec and can have an issue associated with it I recommend using marked.json found here: https://github.com/8fold/marked/blob/1f98424064ee27b59d616e9a1ce707658a06ce79/test/specs/marked/marked.json
That's a broader PR and is only meant to show the test setup. The big thing is referencing the issue number. Don't worry about example numbers, I'll fix mine if necessary.
ps. marked-spec.js and marked.json exist in master now.
Same problem, table is rendered to p.
Remove top && and it works.So big-brother(大兄弟), can you modify it and close this issue?It's terrible to manually modify lib/marked.js both dev and prod. T_T
Most helpful comment
After a little of debug, I found the line where the table is ignored:
As the table is nested in the list item,
top === false, so the table syntax is not considered a table anymore.In GFM a table can be defined in a non-top level (as demonstrated in my example), so... I think this can be a bug.