io-george
## Summary Mermaid sequence diagrams whose participants are declared with `actor` (instead of `participant`) fail to render. The diagram is silently left as raw Mermaid source in the output instead of being drawn as box-drawing ASCII art. ## Reproduction Render a file containing: ```` ```mermaid sequenceDiagram actor U as User participant CU as Gateway check user U->>CU: Click AskJLR button ``` ```` Expected: an ASCII sequence diagram. Actual: the raw Mermaid text is shown. ## Analysis The sequence parser only recognizes the `participant` keyword. The declaration regex at `viewmd/mermaid/sequence/parser.py:15` is: ```python _PARTICIPANT_RE = re.compile( r'(?i)^\s*participant\s+(?:"([^"]+)"|(\S+))(?:\s+as\s+(.+))?$' ) ``` An `actor` line matches no rule in the parse loop and hits the catch-all at `parser.py:304`, raising: ``` MermaidError: line 2: invalid syntax: "actor U as User" ``` Per the fallback in `viewmd/mermaid/preprocess.py:60`, a diagram that fails to parse is left untouched — so a single unrecognized `actor` line drops the *entire* diagram back to raw source. Diagrams commonly lead with `actor U as User`, so this is the only blocker for otherwise-valid documents (confirmed: swapping `actor` → `participant` renders correctly). ## Proposed fix Accept `actor` as a synonym for `participant`. In Mermaid the two are semantically identical for a sequence diagram — `actor` only changes the glyph to a stick figure — so the parser should treat an `actor` declaration exactly as a `participant`. One-line change, using a non-capturing group so the existing capture indices (and `_parse_participant`) are untouched: ```python _PARTICIPANT_RE = re.compile( r'(?i)^\s*(?:participant|actor)\s+(?:"([^"]+)"|(\S+))(?:\s+as\s+(.+))?$' ) ``` The trailing `\s+` after the keyword already prevents collisions with a participant literally named `actor` in a message (e.g. `actor->>B: hi` has no space, so it falls through to the message rule — same protection `participant` already relies on). Verified with the reproduction above plus an `alt` fragment: participants render as boxes with correct labels, fragments still draw. ## Scope note This renders actors as boxes, identical to participants. Drawing actual stick-figure glyphs for `actor` would be a larger, separate change; this issue only covers making `actor` diagrams render at all. ## Tests Add a parser test that an `actor` declaration produces a participant (with `as` label), and a render/golden test for a small `actor`-led diagram.