Auto-quote unquoted quadrantChart labels so the Mermaid v11 lexer
accepts them. The Mermaid quadrantChart grammar treats unquoted
labels as a restricted token class โ em-dashes (โ, U+2014),
en-dashes (โ, U+2013), ellipsis (โฆ), parentheses, colons, and
non-ASCII currency symbols (โฌ) all trigger
Lexical error โฆ Unrecognized text and prevent the diagram from
rendering, leaving the raw <pre> source visible on the page.
The style guide already instructs authors to wrap every quadrant /
axis / data-point label in double quotes (see
analysis/methodologies/political-style-guide.md ยง Standard
quadrantChart init block), but AI-generated article.md files
occasionally drop the quoting. Rather than reject the article at
Stage C we sanitize at the renderer boundary so every published
HTML page renders, regardless of upstream authoring discipline.
Sanitization is deliberately scoped to quadrantChart blocks โ
flowchart, sequenceDiagram, mindmap, pie, gantt, and
xychart-beta accept the same Unicode characters in their unquoted
labels and are passed through unchanged.
Lines normalised:
x-axis Left --> Right โ x-axis "Left" --> "Right"
y-axis Low --> High โ y-axis "Low" --> "High"
quadrant-N Label text โ quadrant-N "Label text"
Data Label: [x, y] โ "Data Label": [x, y]
Already-quoted operands are preserved byte-for-byte. The title
line, the %%{init:โฆ}%% directive, and any line not matching one
of the recognised shapes are also left untouched.
Parameters
content: string
Raw mermaid fence body
Returns string
The same content with quadrantChart labels auto-quoted;
the input string is returned unchanged for non-quadrant
diagrams or when no edits are required.
Auto-quote unquoted
quadrantChartlabels so the Mermaid v11 lexer accepts them. The MermaidquadrantChartgrammar treats unquoted labels as a restricted token class โ em-dashes (โ, U+2014), en-dashes (โ, U+2013), ellipsis (โฆ), parentheses, colons, and non-ASCII currency symbols (โฌ) all triggerLexical error โฆ Unrecognized textand prevent the diagram from rendering, leaving the raw<pre>source visible on the page.The style guide already instructs authors to wrap every quadrant / axis / data-point label in double quotes (see
analysis/methodologies/political-style-guide.mdยง StandardquadrantChartinit block), but AI-generatedarticle.mdfiles occasionally drop the quoting. Rather than reject the article at Stage C we sanitize at the renderer boundary so every published HTML page renders, regardless of upstream authoring discipline.Sanitization is deliberately scoped to
quadrantChartblocks โflowchart,sequenceDiagram,mindmap,pie,gantt, andxychart-betaaccept the same Unicode characters in their unquoted labels and are passed through unchanged.Lines normalised:
x-axis Left --> Rightโx-axis "Left" --> "Right"y-axis Low --> Highโy-axis "Low" --> "High"quadrant-N Label textโquadrant-N "Label text"Data Label: [x, y]โ"Data Label": [x, y]Already-quoted operands are preserved byte-for-byte. The
titleline, the%%{init:โฆ}%%directive, and any line not matching one of the recognised shapes are also left untouched.