Skip to content

fix: extract inline CSS styles to native SVG attributes for GitHub compatibility#47

Merged
Zir0-93 merged 2 commits into
masterfrom
fix/svg-style-extraction
May 4, 2026
Merged

fix: extract inline CSS styles to native SVG attributes for GitHub compatibility#47
Zir0-93 merged 2 commits into
masterfrom
fix/svg-style-extraction

Conversation

@Zir0-93
Copy link
Copy Markdown
Member

@Zir0-93 Zir0-93 commented May 4, 2026

Summary

  • GitHub's SVG sanitizer strips inline style attributes from embedded SVGs, causing all strokes (package borders, relationship arrows, component separator lines) to disappear when striffs are rendered on GitHub
  • Adds SvgStyleExtractor post-processor that converts CSS style properties (stroke, stroke-width, stroke-dasharray, fill, font-*, etc.) to native SVG presentation attributes that GitHub preserves
  • Non-convertible CSS properties (transform, background) remain in the style attribute
  • Bumps version to 3.9.1

Test plan

  • 9 unit tests for SvgStyleExtractor covering stroke conversion, dash arrays, mixed convertible/non-convertible, pass-through, font properties, and existing attribute preservation
  • Full mvn verify passes (189 tests, 0 checkstyle violations, 0 PMD violations)
  • Manual: generate a striff SVG and verify it renders correctly on GitHub markdown

🤖 Generated with Claude Code

…mpatibility

GitHub's SVG sanitizer strips inline style attributes, which removes all
stroke, fill, and font properties. This causes lines, relationship arrows,
package borders, and component separators to disappear when SVGs are
rendered on GitHub.

SvgStyleExtractor converts CSS style properties (stroke, stroke-width,
stroke-dasharray, fill, font-*) to native SVG presentation attributes that
GitHub preserves. Non-convertible CSS properties (transform, background)
remain in the style attribute.

Bump version to 3.9.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f8d642591

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +68 to +70
for (Map.Entry<String, String> e : converted.entrySet()) {
replacement.append(' ').append(e.getKey()).append("=\"").append(e.getValue()).append('"');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid emitting duplicate SVG attributes during style extraction

When a node already has a native attribute (for example fill="#fff") and its style also contains the same property (fill:#000), this loop blindly appends another fill/stroke/font-* attribute, producing duplicate attribute names on one element. Duplicate attributes make the SVG not well-formed XML and can cause renderers/sanitizers (including GitHub’s pipeline) to reject or misrender the element, which defeats the compatibility fix for any embedded SVGs that mix presentation attributes and inline style.

Useful? React with 👍 / 👎.

Avoid emitting duplicate attributes when an element already has a native
attribute (e.g. fill="#fff") and the inline style also declares the same
property. The extractor now matches the full opening tag to detect existing
native attributes and skips conversion for those properties.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Zir0-93 Zir0-93 merged commit 3724204 into master May 4, 2026
5 checks passed
@Zir0-93 Zir0-93 deleted the fix/svg-style-extraction branch May 4, 2026 03:01
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