Skip to content

lf-diagram: a quoted flowchart label containing ] is cut at the bracket and the rest of the line is dropped #311

Closed

Description

@max-sixty

A flowchart node whose quoted label contains ] renders cut at that bracket, with the opening quote shown literally, and the rest of the line is lost, including the node the edge points at.

Repro

A page with one lf-diagram:

<lf-diagram id="probe"><pre>
flowchart LR
  A["names: list[str]"] --> B[plain]
</pre></lf-diagram>

version check passes. The rendered diagram has one box, labelled "names: list[str; there is no B box.

The vendored renderer does the same on its own, so it is the parser rather than the widget:

const { renderMermaidSVG } = await import("./skills/leaf/packages/diagram/vendor/beautiful-mermaid.esm.js");
const svg = renderMermaidSVG('flowchart LR\n  A["names: list[str]"] --> B[plain]', {});
// one <rect>, and one <text>: "&quot;names: list[str"

A quoted label holding parentheses or commas renders whole (A["f()"], A["a, b"]), so it is the closing bracket inside the quotes specifically.

Expected

Mermaid's flowchart grammar allows ] inside a quoted label, so either the label renders whole, or version check refuses the source with a diagnostic naming the node. Today the check passes and the reader sees a partial diagram with a node silently missing.

Seen on leaf 372a97c.

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

Activity

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

    @leaf-agent
    Collaborator

    Reproduced, and it is the tokenizer rather than anything about quoting in particular. beautiful-mermaid's NODE_PATTERNS read a label as (.+?) up to the first closing delimiter and never look at the quotes, so the match ends inside the label and the remainder of the line stops parsing as an edge; quotes are stripped later, at normalize time, which is why the opening one survives into the drawing. The same shape cuts A{"m{k}"} and A("f(x)"). It is open upstream as lukilabs/beautiful-mermaid#125 since June, and 1.1.3 is the latest release, so no pin bump carries a fix.

    I took the second branch of your Expected. #312 makes lf-diagram refuse the source alongside the click/accTitle/accDescr directives it already refuses for the same reason, so the reader gets an error box naming the label and version check --render reports it instead of passing on a diagram missing a node.

    The guard reads the delimiter run that actually follows each quoted span rather than banning ] outright, so the shapes that already render it stay working — A[["names: list[str]"]], A(["names: list[str]"]) and A -->|"list[str]"| B all draw whole, and those two doubled-closer shapes are the workaround references/authoring-evidence.md now points an author at. It can come out when an upstream release closes #125.

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