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

GFM doesn't handle escaped pipes in code blocks #1237

Closed
tomtheisen opened this issue Apr 23, 2018 · 3 comments · Fixed by #1239
Closed

GFM doesn't handle escaped pipes in code blocks #1237

tomtheisen opened this issue Apr 23, 2018 · 3 comments · Fixed by #1239
Labels
help wanted L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue parser: GFM

Comments

@tomtheisen
Copy link

Marked version: 0.3.19

Markdown flavor: GitHub Flavored Markdown

Expectation

I expect that pipes will be parsed in accordance with the GFM specification, such as example 193. It's labeled "Include a pipe in a cell’s content by escaping it, including inside other inline spans:". The example indicates that you can include a pipe in a code block in a table by escaping it with a backslash.

Result

| f\|oo  |
| ------ |
| b `\|` az |
| b **\|** im |

When rendering this document with GFM turned on, the pipes in the code blocks actually create new table cells.

Marked Demo: https://codepen.io/recursive/pen/yjeBVW - I didn't use marked.js.org because I couldn't see how to turn on GFM from there.

What was attempted

Here's the code I'm using.

let m = "| f\|oo  |\n| ------ |\n| b `\|` az |\n| b **\|** im | \n";
marked.setOptions({gfm: true});
let h = marked(m);
document.getElementById("out").innerHTML = h;
@joshbruce
Copy link
Member

@tomtheisen: Thanks for submitting and including an example from the spec.

Confirmed.

See 'GFM 0.28 Tables' test suite https://github.com/markedjs/marked/blob/master/test/specs/gfm/gfm-spec.js

Note that 193 is a known failure. The most timely solution would be to submit a PR, if you are able.

@joshbruce joshbruce added L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue help wanted parser: GFM labels Apr 23, 2018
@tomtheisen
Copy link
Author

I didn't realize this was a known bug. After doing some further search, I found another issue on the same subject. For the benefit of any readers looking for info, buried in the comments, there's a workaround.

Basically use <code>foo&#124;</code> to represent code spans with pipes inside a table. I still may work on a pull request if I have time.

@tomtheisen tomtheisen mentioned this issue Apr 25, 2018
6 tasks
@tomtheisen
Copy link
Author

@joshbruce: PR is here

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 parser: GFM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants