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

Reference-style links inside tables are broken since version 3 #2217

Closed
elishowk opened this issue Sep 28, 2021 · 5 comments · Fixed by #2471
Closed

Reference-style links inside tables are broken since version 3 #2217

elishowk opened this issue Sep 28, 2021 · 5 comments · Fixed by #2471
Labels
category: links category: tables L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue released

Comments

@elishowk
Copy link

Marked version: 3+

Describe the bug

Reference-style links inside tables are broken since version 3. Version 2.1.3 works fine.

[I'm a reference-style link][Arbitrary case-insensitive reference text]

To Reproduce

  1. Install marked npm install --save marked@3.0.4

Expected behavior

@UziTech UziTech added category: links category: tables L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue labels Sep 28, 2021
@tHeCh0s3n0n3
Copy link

I ran into this very issue and did a bit of troubleshooting (I'm using a custom renderer).

What I found was that the tablecell render function receives a rendered link as the content in the following cases which is the expected behavior:

The bug only appears when the link reference is declared below where it is referenced.

The simplest workaround would be to move your link reference declarations to the top of the markdown file.

@Martii
Copy link
Contributor

Martii commented Jan 16, 2022

@tHeCh0s3n0n3

The bug only appears when the link reference is declared below where it is referenced.

The simplest workaround would be to move your link reference declarations to the top of the markdown file.

Interesting... doesn't appear to be needed exactly at the top of the .md file though as you alluded to... just above the references. This is what has been stopping us from migrating to a newer marked.

Not sure I want to ask all of our users to do this though... not to mention any comments to be fixed. OY.

Thanks for the workaround mention.

@ashharrison90
Copy link

ashharrison90 commented Jan 19, 2022

also seeing this.

wrote an ugly little failing test case:

it('should correctly parse reference links in tables', () => {
  const md = `
| Column 1 | Column 2             |
|----------|--------------------- |
| Foo      | [Bar][referenceLink] |

[referenceLink]: https://www.google.com
  `;
  const html = marked(md);
  expect(html).toBe(`<table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody><tr>
<td>Foo</td>
<td><a href="https://www.google.com">Bar</a></td>
</tr>
</tbody></table>
`);
});

and a quick git bisect looks like it was introduced with #2124

@willeastcott
Copy link

The PlayCanvas Developer Site was just affected by this too. We recently upgraded marked and all reference style links in markdown tables stopped working (without us noticing at first). I have now switched them all to inline links. So while we're OK after this fixing up, it'd be great to get reference style links in tables working again.

@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.16 🎉

The release is available on:

Your semantic-release bot 📦🚀

Martii added a commit to Martii/OpenUserJS.org that referenced this issue May 24, 2022
* *marked* seems to have finally fixed tables... seems 1 to 1... still has issues with html tags per OpenUserJS#1775 via markedjs/marked#2217 and markedjs/marked#2471
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: links category: tables L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants