Skip to content

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

Closed
@tomtheisen

Description

@tomtheisen

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    L1 - brokenValid usage causes incorrect output OR a crash AND there is no known workaround for the issuehelp wantedparser: GFM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions