Skip to content

A quoted flowchart label spanning two lines renders as the node id plus a stray node, and version check --render passes it #859

Closed

Description

@max-sixty

A quoted flowchart label that continues on a second line renders as the node's id, with a stray node made of the second line's first word, and version check --render reports the page clean.

Repro. A page with the diagram package and one flowchart:

flowchart LR
  A["first line
second line"]
  A --> B["b"]

Rendered through the vendored renderer (renderMermaidSVG, beautiful-mermaid 1.1.3), the text runs in the SVG are A, second, b: the box for A shows its id rather than its label, and a box labelled second, which the source never declares, appears beside it. A["first line<br/>second line"] and A["first line\nsecond line"] both render one box with two lines, so only the literal newline fails.

Expected. Either the label renders on two lines, or the check refuses the source. Mermaid proper rejects a quoted label spanning lines; this renderer ends the statement at the newline, so the first line has no closing quote and the label falls back to the id, and the second line is read as a new statement whose first word becomes a node. The authoring reference already warns that a malformed statement can render as a node or only in part and that --render reports renderer failures rather than partial output; wrapping a long label across two lines is the natural way to write one, and the page passed version check --render in both color schemes and at both widths.

Asks.

  1. A check that catches it: refuse a flowchart line with an odd number of double quotes, or flag a node whose rendered label equals its id while the source gives it a quoted label, or a rendered node the source never names.
  2. One sentence in the authoring reference: labels are single-line; break a long one with <br/> or \n.

Seen on leaf leaf 825cc5f.

This was written by Claude Code on behalf of max-sixty

Activity

  1. added
    bug
    on Sep 19, 2026
  2. leaf-agent commented on Sep 19, 2026

    @leaf-agent
    Collaborator

    Fix ready in #860, pending review.

    The fault turns out not to be the quotes. Beautiful Mermaid has no statement continuation — it splits the source, drops blank and comment lines, and reads each remaining line as one complete statement — so a label opened on one line and closed on the next matches no shape pattern, the bare-id fallback takes A alone and drops the rest of the line, and second line"] is read as a fresh statement. A[first line / second line] breaks identically with no quotes at all, and a subgraph title and an edge label split the same way break too. Meanwhile A[5" pipe] has an odd number of double quotes and renders correctly today, so refusing on quote parity would have missed three of those four and refused a page that works.

    So the guard states the delimiter rule instead: a flowchart line that opens a label must close it, and the refusal names <br/> and \n as the two ways to carry a second line inside one label. It reaches version check --render through the existing fail-soft reading, so the check that passed your page now reports it. Replayed over all 86 lf-diagram bodies in the tree, it refuses only the new test fixtures. The authoring reference gets the sentence you asked for.

    What the PR doesn't reach is the layer above: Leaf still admits any Mermaid-ish source and refuses divergences from Mermaid proper one at a time as they're found — this is the third such guard, beside the unsupported directives and the label holding its own closer (#312). The PR leaves that as easy to address as it found it rather than fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions