okforest/d2-syntax
d2 code blocks are valid D2 (diagrams as code).
D2 is a language for writing diagrams as text, and OKForest draws d2 code blocks as diagrams. This check compiles each one with D2’s own compiler and reports the first syntax error, with its line; the D2 tour teaches the syntax. The CLI checks D2 only when @d2lang/d2 is installed alongside it (diagram checks); otherwise the blocks are reported as okforest/diagram-unchecked. The GitHub Action always checks them.
Example
Section titled “Example”This file breaks the rule:
---type: Metrictitle: Monthly churndescription: The share of customers who cancel in a month.---
How a cancellation reaches the churn report:
```d2billing -> warehouse: nightly exportwarehouse -> {```okforest validate reports:
churn.md 11:1 error D2 syntax error: connection missing destination okforest/d2-syntax 11:14 error D2 syntax error: maps must be terminated with } okforest/d2-syntaxFixed:
---type: Metrictitle: Monthly churndescription: The share of customers who cancel in a month.---
How a cancellation reaches the churn report:
```d2billing -> warehouse: nightly exportwarehouse -> report: monthly churn```