Standard code blocks
Use triple backticks with an optional language identifier:Extended attributes
Append{attrs} after the language identifier to customize rendering:
Render as image
Convert code blocks to PNG images in the exported document. This preserves syntax highlighting exactly as displayed:Custom background color
Alignment and spacing
Attribute reference
| Attribute | Values | Description |
|---|---|---|
renderAsImage | true, false | Render code as a PNG image in the exported document |
backgroundColor | CSS color (e.g., "#1e1e1e") | Background color of the code block |
width | Number (pixels, 10–2000) | Width of the rendered image |
align | left, center, right | Horizontal alignment |
spacingBefore | Number (pt) | Spacing before the code block |
spacingAfter | Number (pt) | Spacing after the code block |
The
renderAsImage option is particularly useful for PDF/DOCX exports where you want pixel-perfect syntax highlighting. Without it, code blocks are rendered as styled text.