Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indented tables are ignored #1246

Closed
wpomier opened this issue May 1, 2018 · 5 comments · Fixed by #1446
Closed

Indented tables are ignored #1246

wpomier opened this issue May 1, 2018 · 5 comments · Fixed by #1446
Labels
help wanted L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue

Comments

@wpomier
Copy link

wpomier commented May 1, 2018

Marked version: 0.3.19
Markdown flavor: GitHub Flavored Markdown
Github commit: b78deebf

Issue Description

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

Result

It should be rendered to:

  • Marked doesn't work with indented tables like this:

    column1 column2
    value1 value2
    value3 value4

What was attempted

Basic usage.

var html = marked(example);
@wpomier
Copy link
Author

wpomier commented May 2, 2018

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.

@UziTech
Copy link
Member

UziTech commented May 2, 2018

@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

@joshbruce
Copy link
Member

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.

@UziTech UziTech added the L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue label May 2, 2018
@joshbruce
Copy link
Member

ps. marked-spec.js and marked.json exist in master now.

@LitileXueZha
Copy link

LitileXueZha commented Aug 26, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants