Skip to content

Add classDef/style support to state diagrams#4

Open
theletterf wants to merge 1 commit intonullean:mainfrom
theletterf:feat/state-classdef
Open

Add classDef/style support to state diagrams#4
theletterf wants to merge 1 commit intonullean:mainfrom
theletterf:feat/state-classdef

Conversation

@theletterf
Copy link
Copy Markdown

Summary

  • Parse classDef, class, style, and :::shorthand directives in StateParser
  • Handle classDef default for auto-assigning all states without explicit class
  • Support ::: on both source and target in transitions (e.g., Source:::myClass --> Target:::otherClass)
  • No layout/renderer changes needed — existing pipeline already resolves and applies styles from MermaidGraph dictionaries

Changes

  • StateParser.cs — 4 new regex patterns, parsing logic, ParseStyleProps helper
  • StateParserTests.cs — 14 new TUnit tests
  • StateSpecTests.ClassDef_and_style.verified.svg — snapshot for full example

Test plan

  • 14 parser tests covering classDef, class, style, :::, default, regression
  • 1 snapshot spec test rendering the full example through the SVG pipeline
  • All 429 tests pass (415 existing + 14 new)

🤖 Generated with Claude Code

- Parse classDef, class, style, and :::shorthand directives in StateParser
- Handle classDef default for auto-assigning all states
- Support ::: on both source and target in transitions
- 14 new parser tests + 1 snapshot spec test
- No layout/renderer changes needed (existing pipeline already resolves styles)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant