EU Parliament Monitor โ€” API Documentation - v0.9.6
    Preparing search index...

    Function sanitizeMermaidQuadrantChart

    • 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.