docusaurus: Can't use math expressions using '|' in Markdown tables (remark-math/KaTeX/GFM)

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

| $1$       | $2$       |
| --------- | --------- |
| $|3| = 3$ | $|4| = 4$ |

will be rendered like:

image

The ‘|’ inside the latex expression is mistaken for a separator for the sheet.

Reproducible demo

No response

Steps to reproduce

write

| $1$       | $2$       |
| --------- | --------- |
| $|3| = 3$ | $|4| = 4$ |

inside a doc.

Expected behavior

The ‘|’ in the latex expression is processed correctly.

Actual behavior

The ‘|’ in the latex expression is mistaken for a separator for the sheet.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:latest
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):Microsoft Edge, Node.js 18.12.1
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):Windows 11

Self-service

  • I’d be willing to fix this bug myself.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

Hey

This is already fixed for Docusaurus v3 with MDX v2. You’ll have to escape the pipes with \| in math expressions.

| $1$         | $2$         |
| ----------- | ----------- |
| $\|3\| = 3$ | $\|4\| = 4$ |
CleanShot 2023-08-31 at 12 14 21@2x

I’m not sure there’s a good way to do that under Docusaurus v2 (MDX v1). My suggestion would be to wait for Docusaurus v3, it should move to beta very soon.