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

Heading immediately following a table is being rendered in the table element #1467

Closed
Labels
category: tables L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue

Comments

@Thomas-James-Rose
Copy link

Thomas-James-Rose commented Apr 10, 2019

Describe the bug
I have some Markdown that contains a table immediately followed by a heading on a new line. The subsequent heading is being rendered as part of the table.

To Reproduce
Steps to reproduce the behaviour:

Markdown Sample:

| Heading | Description |
| ----------- | ----- |
| Heading 1 | Some description | 
| Heading 2 | Some other description |
## A Title that is not a part of the table

HTML output:

<table>
  <thead>
    <tr>
      <th>Heading</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Heading 1</td>
      <td>Some description</td>
    </tr>
    <tr>
      <td>Heading 2</td>
      <td>Some other description</td>
    </tr>
    <tr>
      <td>## A title that is not a part of the table</td>
      <td></td>
    </tr>
  </tbody>
</table>

Demo:
Marked Demo

Expected behaviour
The heading should be rendered separately from the table.

@UziTech
Copy link
Member

UziTech commented Apr 10, 2019

You should add a blank line between then

@UziTech UziTech added L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue category: tables labels Apr 10, 2019
@Thomas-James-Rose
Copy link
Author

A usable workaround in a lot of cases but, unfortunately, in our use case the Markdown being parsed is both authored by other people and there is a high volume of it so it is not really viable for us to update and fix things in this way.

@UziTech
Copy link
Member

UziTech commented Apr 11, 2019

You could change the markdown when you parse it

const html = marked(markdown.replace(/[^\n]\n#/g, '\n\n#'));

This is very low priority for us since there is an easy way to fix it.

PRs are welcome 😁

@Thomas-James-Rose
Copy link
Author

Thanks! 🙂 I'll try find some time to give it a look. I've noticed a similar issue with lists.

@Thomas-James-Rose
Copy link
Author

^ I've raised a PR to address this issue.

@calculuschild
Copy link
Contributor

Commenting here to note we are running into the same issue but with <hr> immediately after tables. GFM spec says this shouldn't happen.

@UziTech
Copy link
Member

UziTech commented Feb 4, 2020

@calculuschild PRs are always welcome. You can look at #1469 as a starting point.

@UziTech UziTech mentioned this issue Mar 6, 2020
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment