markdown_syntax_error
HTTP 422 · code: "markdown_syntax_error" · type: https://docs.formfeed.dev/errors/markdown-syntax-error
A Markdown document holds a formula that KaTeX cannot typeset (with settings.markdown.math) or a diagram that Mermaid cannot draw (with settings.markdown.diagrams), or more of them than a document may hold, so nothing was rendered. A PDF is sent to someone, so the render fails instead of printing an error box into the page. The render is recorded as failed and costs nothing.
location.line names the line, counted from the top of the text you sent, front matter included; with an engine, it is the line of the text the template rendered. part says what could not be read: math, a formula, or diagram, a diagram. detail gives KaTeX's or Mermaid's own message.
Example
{
"type": "https://docs.formfeed.dev/errors/markdown-syntax-error",
"title": "Markdown syntax error",
"status": 422,
"detail": "The formula on line 12 does not parse: Undefined control sequence: \\frak",
"code": "markdown_syntax_error",
"location": { "line": 12 },
"part": "math",
"render_id": "rnd_4f3a9c2e7b1d4e6f8a0b2c4d6e8f0a12",
"request_id": "req_9a1c3e5b7d0f2a4c6e8b0d2f4a6c8e0b"
}
A diagram says "part": "diagram" and a detail such as The diagram on line 31 cannot be drawn: Expecting 'AMP', 'COLON', 'PIPE', got 'EOF'. render_id is there when a synchronous render failed; an async render keeps the same information in its error (code, message, line, part).
Common causes
In a formula:
- A brace, an argument or an environment that is not closed:
\frac{1}without its second argument,\left(without\right),\begin{aligned}without\end{aligned}. - A command KaTeX does not know, such as
\frakfor\mathfrakor a macro of your own LaTeX preamble. Define it in the document with\gdef, which holds for every formula after it. - A
$$that is never closed: a line that starts with$$opens a formula, and only a line that ends in$$closes it. - A
&outside an environment that aligns, such asalignedorcases. - A command that would link, load a picture or write HTML:
\href,\url,\includegraphics,\htmlClass,\htmlId,\htmlStyleand\htmlDataare refused. - Money read as a formula: with
mathon,between $5 and 10$ a monthholds a formula, because the second$follows a digit and stands before a space. Write\$for a dollar sign.
In a diagram:
- A line Mermaid's grammar does not take, such as an arrow without its end (
A -->) or-->>in a flowchart, which only a sequence diagram takes. - A first line that names no kind of diagram Mermaid knows: it starts with
flowchart,sequenceDiagram,pieand the like. - More than 500 edges, Mermaid's own limit.
And the limits: a formula over 4 kB of TeX, more than 1,000 formulas or more than 256 kB of TeX together, a diagram over 50 kB, or more than 50 diagrams.
How to fix it
- Go to
location.lineand correct the formula or diagram there, or write a dollar sign that is meant as money as\$. - Check a formula against what KaTeX supports, and a diagram against Mermaid's syntax; Mermaid's live editor shows the same message.
- A document that holds money and no formulas does not need
math, nor one without diagramsdiagrams: both are off by default.
Retry?
No. The same request gets the same answer. Correct the text and send it again with a new Idempotency-Key or without one: a 4xx answer is stored under its key for 24 hours, so the old key returns this problem again. See retrying.