Skip to content

Support Pandoc-style attributes for diagram code blocks - #50

Merged
patakuti merged 1 commit into
mainfrom
feature/pandoc-code-attrs
May 18, 2026
Merged

Support Pandoc-style attributes for diagram code blocks#50
patakuti merged 1 commit into
mainfrom
feature/pandoc-code-attrs

Conversation

@patakuti

Copy link
Copy Markdown
Owner

Closes #49

Summary

  • Extend the fenced code block regex to recognize {.lang} and {.lang key=value ...} (Pandoc-style) in addition to the plain ```lang form
  • Parse width and height attributes and apply them as max-width / max-height inline CSS on the rendered container (<pre class="mermaid">, <div class="svg-container">, <div class="plantuml-container">)
  • Invalid or unsafe CSS values (e.g. width=abc) are silently ignored
  • Applies to all three diagram types: mermaid, svg, plantuml

Test plan

  • {.mermaid width=700} renders with max-width: 700px
  • {.mermaid width=50%} renders with max-width: 50%
  • {.mermaid height=400} renders with max-height: 400px
  • {.mermaid width=700 height=400} renders both constraints
  • {.mermaid width=abc} produces no style attribute
  • {.mermaid} (no attrs) produces no style attribute
  • {.svg width=300} applies style to svg-container
  • {.plantuml width=600} applies style to plantuml-container
  • Plain ```mermaid still works unchanged
  • All existing tests pass

🤖 Generated with Claude Code

Add support for ```{.mermaid width=700} syntax and apply width/height
attributes as CSS max-width/max-height on the rendered container element.
Applies to mermaid, svg, and plantuml blocks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@patakuti
patakuti merged commit 8ffebe5 into main May 18, 2026
1 check passed
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.

Support Pandoc-style attributes for diagram code blocks

1 participant