Conversation
Co-authored-by: Pushpinder Pal Singh <sayhi@swiftlysingh.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughA new node styling feature is introduced to the DSL parser through a preprocessing pass that recognizes Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds DSL support for styling nodes via inline @key:value attributes and @node style blocks, propagating those styles through layout and Excalidraw generation.
Changes:
- Extend DSL parsing to recognize inline node style attributes and
@nodestyle blocks, merging defaults and overrides into deduplicated nodes. - Add validation for supported style keys and allowed values.
- Document the new styling syntax and add unit tests covering parsing, merging, validation, and generation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/unit/parser/dsl-parser.test.ts | Adds test coverage for inline styles, @node blocks, precedence/merging rules, validation errors, and style propagation into generated elements. |
| src/parser/dsl-parser.ts | Implements style parsing/validation, @node block preprocessing, and merges block + inline styles into deduplicated graph nodes. |
| README.md | Documents inline style attributes, @node blocks, supported keys/values, and precedence rules. |
| man/excalidraw-cli.1 | Updates CLI man page to include node styling syntax and examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (!trimmed.startsWith('@node ')) { | ||
| outputLines.push(line); | ||
| continue; | ||
| } | ||
|
|
||
| const selector = trimmed.slice('@node'.length).trim(); |
There was a problem hiding this comment.
preprocessNodeStyleBlocks only detects node-style blocks when the trimmed line starts with the literal string "@node " (space). If the DSL uses a tab or multiple spaces after @node (e.g. @node\t[Login]), the block will be ignored and tokenized as a normal directive instead, so styles won’t be applied. Consider matching @node with a whitespace regex (e.g. /^@node\b/) and then parsing the selector after any whitespace to make the directive robust and consistent with other directive parsing.
| if (!trimmed.startsWith('@node ')) { | |
| outputLines.push(line); | |
| continue; | |
| } | |
| const selector = trimmed.slice('@node'.length).trim(); | |
| const nodeDirectiveMatch = trimmed.match(/^@node\s+(.+)$/); | |
| if (!nodeDirectiveMatch) { | |
| outputLines.push(line); | |
| continue; | |
| } | |
| const selector = nodeDirectiveMatch[1].trim(); |
| Rectangle node with inline style attributes. | ||
| .TP | ||
| .BI "@node [Label]" | ||
| Start a node-style block followed by indented |
There was a problem hiding this comment.
The man page describes [Label @key:value ...] as a "Rectangle node with inline style attributes" and shows @node [Label], but inline styles and @node selectors are supported for other node syntaxes too (e.g. {...}, (...), [[...]]). Updating this wording/examples to refer to “shape nodes” (or “any node selector”) would avoid misleading users about the feature scope.
| Rectangle node with inline style attributes. | |
| .TP | |
| .BI "@node [Label]" | |
| Start a node-style block followed by indented | |
| Shape node with inline style attributes. | |
| .TP | |
| .BI "@node <node-selector>" | |
| Start a node-style block for a node selector followed by indented |
Summary
@nodestyle blocksTesting
npm run buildnpm run test:run -- tests/unit/parser/dsl-parser.test.tsImplements #22
Summary by CodeRabbit
New Features
@key:valueattributes and reusable@nodestyle blocks.Documentation
Tests