Skip to content

Latex support #334

@v-goncharenko

Description

@v-goncharenko

Context

I use Latex in my Markdown, then it is rendered with MathJax (in Jupyter Notebook).

But now mdformat reformats my Latex code as follows:

$$
-    "\\begin{equation}\n",
+    "\\\\begin{equation}\n",

-    "d(x, y) = \\sqrt{\\sum_{i = 1}^n (x_i - y_i)^2}\n",
+    "d(x, y) = \\\\sqrt{\\\\sum\\_{i = 1}^n (x_i - y_i)^2}\n",

-    "\\end{equation}\n",
+    "\\\\end{equation}\n",
$$

So after formatting it stops to be valid Latex and renders as string.

Proposal

Escape Latex notation in mdformat.

  1. Easy way - just escape (left as is) everything inside $$ ... $$ block (and maybe in $ ... $ block). But this is error prone =(
  2. Harder way - borrow parser ideas from Jupyter, MathJax, etc. This requires some research.

Tasks and updates

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions