Skip to content

okforest/d2-syntax

errorOKForest conventions

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.

This file breaks the rule:

churn.md
---
type: Metric
title: Monthly churn
description: The share of customers who cancel in a month.
---
How a cancellation reaches the churn report:
```d2
billing -> warehouse: nightly export
warehouse -> {
```

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-syntax

Fixed:

churn.md
---
type: Metric
title: Monthly churn
description: The share of customers who cancel in a month.
---
How a cancellation reaches the churn report:
```d2
billing -> warehouse: nightly export
warehouse -> report: monthly churn
```