Skip to content

inlineCode inside table been parsed incorrectly #80

Closed as not planned
Closed as not planned

Description

@fisker

Initial checklist

Affected package

remark-gfm@4.0.1

Steps to reproduce

import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import { unified } from "unified";

const processor = unified().use(remarkParse).use(remarkGfm);

const text = `
| a       |
| ------- |
| \`b \\| c\` |
`;

const file = await processor.run(processor.parse(text));

console.log(file.children[0].children[1].children[0].children[0]);

Actual behavior

{
  type: 'inlineCode',
  value: 'b | c',
  position: {
    start: { line: 4, column: 3, offset: 27 },
    end: { line: 4, column: 11, offset: 35 }
  }
}

Expected behavior

The value should be b \| c.

Runtime

node@22.14.0

Package manager

yarn

Operating system

Windows

Build and bundle tools

No response

Activity

  1. added
    👋 phase/newPost is being triaged automatically
    🤞 phase/openPost is being triaged manually
    and removed
    👋 phase/newPost is being triaged automatically
    on Dec 9, 2025
  2. seiyab commented on Dec 9, 2025

    @seiyab

    I suspect that it's correct in remark-gfm side. | in inline code have to be escaped if it's in table cell.

    https://github.github.com/gfm/#example-200

    Include a pipe in a cell’s content by escaping it, including inside other inline spans

    | a       |
    | ------- |
    | `b \| c` |

    ↓ Rendered as

    a
    b | c

    So Prettier needs its own workaround, I suppose.

  3. fisker commented on Dec 9, 2025

    @fisker
    Author

    I didn't know it renders as b | c. Thanks!

  4. github-actions commented on Dec 9, 2025

    @github-actions
  5. wooorm commented on Dec 9, 2025

    @wooorm
    Member

    yep, this is how it works in GFM tables!

  6. added
    👎 phase/noPost cannot or will not be acted on
    and removed
    🤞 phase/openPost is being triaged manually
    on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙋 no/questionThis does not need any changes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions