Skip to content

Add DSL node styling support#25

Merged
swiftlysingh merged 1 commit intomainfrom
cursor/custom-fonts-support-95e2
Apr 3, 2026
Merged

Add DSL node styling support#25
swiftlysingh merged 1 commit intomainfrom
cursor/custom-fonts-support-95e2

Conversation

@swiftlysingh
Copy link
Copy Markdown
Owner

@swiftlysingh swiftlysingh commented Apr 3, 2026

Summary

  • add DSL parser support for inline node style attributes and @node style blocks
  • merge block defaults and inline overrides into deduplicated graph nodes
  • document the new DSL styling syntax and cover parsing/generation behavior with tests

Testing

  • npm run build
  • npm run test:run -- tests/unit/parser/dsl-parser.test.ts

Implements #22

Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added node styling capabilities with inline @key:value attributes and reusable @node style blocks.
    • Supported style properties include fillStyle, backgroundColor, strokeColor, strokeWidth, strokeStyle, roughness, and opacity with defined precedence rules.
  • Documentation

    • Updated README and man page with comprehensive node styling syntax documentation and examples.
  • Tests

    • Added extensive test coverage for node styling parsing, validation, and output generation.

Co-authored-by: Pushpinder Pal Singh <sayhi@swiftlysingh.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new node styling feature is introduced to the DSL parser through a preprocessing pass that recognizes @node block directives with style key-value pairs and inline @key:value attributes on node labels. Styles are validated, parsed (with numeric and enum conversions), and merged with block-level defaults overridden by inline attributes. Documentation is updated to describe the syntax and merge precedence rules.

Changes

Cohort / File(s) Summary
Documentation
README.md, man/excalidraw-cli.1
Extended DSL syntax documentation with new inline styled-node form [Label @key:value ...] and @node block directives; added "Node Styling" sections describing supported style keys and merge precedence.
Parser Implementation
src/parser/dsl-parser.ts
Added preprocessing pass to recognize and validate @node style blocks; extended node token parsing to extract inline @key:value attributes; implemented mergeNodeStyles function for applying block defaults and inline overrides to nodes during creation.
Test Coverage
tests/unit/parser/dsl-parser.test.ts
Added comprehensive test cases for inline style parsing, @node block directives, merge behavior, style validation (unsupported keys, invalid values), and integration with layout and code generation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Through @key and styled-node lands I hop,
Where inline colors never stop,
Block defaults dance with inline grace,
Each rectangle finds its place!
A parser's art, a rabbit's delight,
Node styling makes the DSL bright!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add DSL node styling support' directly and concisely summarizes the main change: adding node styling capabilities to the DSL parser, which is the core focus of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/custom-fonts-support-95e2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@swiftlysingh swiftlysingh marked this pull request as ready for review April 3, 2026 05:10
Copilot AI review requested due to automatic review settings April 3, 2026 05:10
@swiftlysingh swiftlysingh merged commit 96445b3 into main Apr 3, 2026
5 of 6 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @node style 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.

Comment thread src/parser/dsl-parser.ts
Comment on lines +225 to +231

if (!trimmed.startsWith('@node ')) {
outputLines.push(line);
continue;
}

const selector = trimmed.slice('@node'.length).trim();
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
Comment thread man/excalidraw-cli.1
Comment on lines +177 to +180
Rectangle node with inline style attributes.
.TP
.BI "@node [Label]"
Start a node-style block followed by indented
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
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.

3 participants