ext:code
Version: 1.0 Status: Stable Identifier: code
Overview
The code extension adds the ability to attach code snippets to diagram nodes. This enables documentation of implementation details, API signatures, or configuration directly within architecture diagrams.
Declaration
#!ext code
@arch My ArchitectureSyntax
Code Section
Define code blocks in a [code] section:
[code]
block_id:language:Title
code content here
more code...Components:
block_id: Unique identifier for the code blocklanguage: Programming language (for syntax highlighting)Title: Display title for the code block
Linking Nodes to Code
Reference code blocks from nodes using |code:block_id:
Supported Languages
Implementations SHOULD support syntax highlighting for common languages:
TypeScript
typescript, ts
JavaScript
javascript, js
Python
python, py
Go
go
Rust
rust
Java
java
SQL
sql
JSON
json
YAML
yaml
Shell
bash, sh
Complete Example
Graceful Degradation
Renderers that do not support ext:code:
MUST parse
[code]sections without errorMUST ignore
|code:...properties on nodesMUST skip rendering of code block content
MUST render all nodes, edges, and groups normally
Example degradation:
With ext:code: Node shows expandable code panel with syntax highlighting
Without ext:code: Node renders normally, code content is not displayed
Implementation Notes
Code Block Display
Implementations may display code blocks as:
Expandable panels attached to nodes
Sidebar panels when node is selected
Hover tooltips
Separate code view tab
Syntax Highlighting
Use standard syntax highlighting libraries (Prism, Highlight.js, etc.)
Fall back to plain text for unknown languages
Preserve whitespace and indentation
Code Block Scope
Code blocks are scoped to the diagram:
Block IDs must be unique within a file
Blocks cannot be referenced across files
Nested diagrams inherit parent code blocks
Version History
1.0 (2026-01-14): Initial release
Last updated