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

Escaped Pipes (in tables) retain escape character (\) #838

Closed
riceboyler opened this issue Nov 6, 2019 · 5 comments
Closed

Escaped Pipes (in tables) retain escape character (\) #838

riceboyler opened this issue Nov 6, 2019 · 5 comments
Labels
🙋 no/question This does not need any changes

Comments

@riceboyler
Copy link

Subject of the issue

When using Markdown Table syntax, using the escape character () for pipes (|) does not remove the escape character when rendered. Example:
image

This is not a place to ask questions. For that, go to Spectrum

Your environment

  • OS: MacOS 10.14
  • Packages: mdx-js 1.5.1
  • Env: Chrome 79, Node 12.11

Steps to reproduce

Tried to create an mvce on CodeSandbox but that was met with frustration. Basically, create a simple component with a Markdown table and attempt to use an escaped pipe in that table:

# Hello, world!

<Button>Here is a button</Button>

|Test|Test2|
|---|---|
|`testy \| testy` | testy |

Expected behaviour

The pipe should be rendered without the preceding escape character

Actual behaviour

The pipe is rendered prepended by the escape character.

@riceboyler riceboyler added 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Nov 6, 2019
@johno johno added 🙆 yes/confirmed This is confirmed and ready to be worked on 🐛 type/bug This is a problem and removed 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Nov 6, 2019
@riceboyler
Copy link
Author

To be fair, I think this bug may lie more in how unified.js handles escaped pipes, but I admittedly don't have enough experience with unified (or ASTs in general) to know.

@wooorm
Copy link
Member

wooorm commented Nov 6, 2019

This indeed has to do with how remark-parse interprets table cells and is a bug there. The escape slash is a literal slash, instead of an escape. We’re working on a replacement that has much better support for MDX.

If you’d like to support us to get there faster, and are able to, please sponsor us on OpenCollective!

@wooorm
Copy link
Member

wooorm commented Apr 21, 2020

Sorry btw, forgot about this issue, but this is, horrible as that may sound, a feature instead of a bug. Escapes (# Hello, world! `\#`) and character references (# Hello, world! `&amp;`) do not work in code: https://spec.commonmark.org/dingus/?text=%23%20Hello%2C%20world!%20%60%5C%23%60

It’s what lets you embed HTML and other things inside code blocks without needing to double encode everything such as &lt;this&gt;

@wooorm wooorm closed this as completed Apr 21, 2020
@wooorm wooorm added 🙋 no/question This does not need any changes and removed 🐛 type/bug This is a problem 🙆 yes/confirmed This is confirmed and ready to be worked on labels Apr 21, 2020
@ThomasEhling
Copy link

Hi @wooorm

Even though this issue is a few years old, our team still has the same issue today.

It's true that Escapes (#Hello, world!`\#`) and character references (#Hello, world!`&amp;``) don't work in code but the real problem here is that the table does not detect that the pipe character is inside the code block and ignores it.

In our product documentation, we specify a lot of shell code with pipe characters and would like our customers to be able to easily copy and paste commands from code blocks. As we move our documentation to Docusaurus which uses MDX, this problem arises.

Our current workaround is to use the HTML <code> tag, but that's not native markdown and makes our documentation markdown messy.

Do you have any new information on this please?

@wooorm
Copy link
Member

wooorm commented Apr 7, 2022

Docusaurus should update to MDX 2, there is already an issue open about it.

Then the behavior of MDX, with remark-gfm (which defines tables), matches exactly how GH handles tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

4 participants