markplus_core 1.0.0

Universal Markdown → AST (JSON) compiler for the MarkPlus ecosystem
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
# MarkPlus AST Reference

Every Markdown construct maps to a JSON node with a `"t"` (type) field.
Block nodes appear at the top level of the `ast` array. Inline nodes appear
inside a parent node's `"children"` array.

All nodes are produced by `markplus_core::parse_document()` or
`markplus_core::parse_body()`.

---

## Quick index

| Node `t` | Kind | Source syntax |
|---|---|---|
| `heading` | block | `# … ######` |
| `paragraph` | block | plain text block |
| `fenced` | block | `` `````` `` |
| `blockquote` | block | `> …` |
| `list` | block | `- …` / `1. …` |
| `list_item` | block (child of list) | each item |
| `table` | block | GFM table |
| `definition_list` | block | GFM definition list |
| `hr` | block | `---` / `***` |
| `html_block` | block | raw HTML block |
| `footnote_def` | block | `[^label]: …` |
| `math_block` | block | `$$ … $$` |
| `raw_html` | inline | inline HTML tag |
| `text` | inline | plain text |
| `em` | inline | `*…*` / `_…_` |
| `strong` | inline | `**…**` / `__…__` |
| `del` | inline | `~~…~~` |
| `sup` | inline | `^…^` |
| `sub` | inline | `~…~` |
| `code_span` | inline | `` `` `` |
| `math_inline` | inline | `$…$` |
| `link` | inline | `[text](url)` |
| `image` | inline | `![alt](src)` |
| `widget` | inline | `:[text]{name …}` |
| `footnote_ref` | inline | `[^label]` |
| `task_marker` | inline | `[ ]` / `[x]` |
| `soft_break` | inline | line break (no `\`) |
| `hard_break` | inline | `  \n` or `\` + newline |

---

## Block nodes

### `heading`

```markdown
# Title
## Section { #my-id .highlight }
```

```json
{
  "t": "heading",
  "level": 1,
  "children": [{ "t": "text", "text": "Title" }]
}
```

With heading attributes (`# Title { #id .class key=val }`):

```json
{
  "t": "heading",
  "level": 2,
  "id": "my-id",
  "classes": ["highlight"],
  "attrs": { "key": "val" },
  "children": [{ "t": "text", "text": "Section" }]
}
```

Fields: `level` (1–6), optional `id`, optional `classes` (array), optional `attrs` (object), `children` (inline array).

---

### `paragraph`

```markdown
This is a paragraph with **bold** and a [link](url).
```

```json
{
  "t": "paragraph",
  "children": [
    { "t": "text",   "text": "This is a paragraph with " },
    { "t": "strong", "children": [{ "t": "text", "text": "bold" }] },
    { "t": "text",   "text": " and a " },
    { "t": "link",   "href": "url", "title": "", "children": [{ "t": "text", "text": "link" }] }
  ]
}
```

Fields: `children` (inline array).

---

### `fenced`

All fenced code blocks — languages, plugins, diagrams — produce the **same**
node shape. The renderer decides what `name` means.

````markdown
```python execute=true linenos
print("hi")
```
````

```json
{
  "t": "fenced",
  "name": "python",
  "attrs": { "execute": "true", "linenos": true },
  "raw": "print(\"hi\")"
}
```

````markdown
```mermaid theme=dark
graph TD
A --> B
```
````

```json
{
  "t": "fenced",
  "name": "mermaid",
  "attrs": { "theme": "dark" },
  "raw": "graph TD\nA --> B"
}
```

Indented code blocks:

```json
{ "t": "fenced", "name": "", "attrs": {}, "raw": "indented content" }
```

Fields: `name` (string, empty for indented), `attrs` (object, may be empty), `raw` (string, trailing whitespace trimmed).

**Attr syntax:** first whitespace-separated token after the language name is the key=value list.
- `key=value``"key": "value"`
- bare `flag``"flag": true`
- `key="quoted value"``"key": "quoted value"`

---

### `blockquote`

```markdown
> Regular quote

> [!NOTE]
> GFM alert note
```

```json
{ "t": "blockquote", "children": [...] }
```

With GFM alert kind:

```json
{ "t": "blockquote", "kind": "note", "children": [...] }
```

`kind` values: `"note"`, `"tip"`, `"important"`, `"warning"`, `"caution"`.

Fields: optional `kind`, `children` (block array from the quote body).

---

### `list`

```markdown
- alpha
- beta

1. first
2. second
```

```json
{
  "t": "list",
  "ordered": false,
  "items": [
    { "t": "list_item", "children": [{ "t": "paragraph", "children": [...] }] },
    { "t": "list_item", "children": [...] }
  ]
}
```

Ordered list:

```json
{ "t": "list", "ordered": true, "start": 1, "items": [...] }
```

Fields: `ordered` (bool), optional `start` (number, only when ordered), `items` (array of `list_item`).

---

### `list_item`

Child of `list`. Contains block-level children (paragraphs, nested lists, etc.).

```json
{ "t": "list_item", "children": [ ... ] }
```

Task list items include a `task_marker` as the first inline child of their paragraph:

```markdown
- [ ] unchecked
- [x] checked
```

```json
{
  "t": "list_item",
  "children": [{
    "t": "paragraph",
    "children": [
      { "t": "task_marker", "checked": false },
      { "t": "text", "text": " unchecked" }
    ]
  }]
}
```

---

### `table`

```markdown
| Name   | Value | Unit |
|--------|-------|------|
| Gain   | 12    | dB   |
```

```json
{
  "t": "table",
  "align": ["none", "none", "none"],
  "headers": [
    { "t": "_cell", "children": [{ "t": "text", "text": "Name" }] },
    { "t": "_cell", "children": [{ "t": "text", "text": "Value" }] },
    { "t": "_cell", "children": [{ "t": "text", "text": "Unit" }] }
  ],
  "rows": [
    [
      { "t": "_cell", "children": [{ "t": "text", "text": "Gain" }] },
      { "t": "_cell", "children": [{ "t": "text", "text": "12" }] },
      { "t": "_cell", "children": [{ "t": "text", "text": "dB" }] }
    ]
  ]
}
```

`align` values per column: `"left"`, `"right"`, `"center"`, `"none"`.

Fields: `align` (array), `headers` (array of `_cell`), `rows` (array of arrays of `_cell`).

---

### `definition_list`

```markdown
Term
: Definition one
: Definition two
```

```json
{
  "t": "definition_list",
  "items": [
    { "t": "_def_title", "children": [{ "t": "text", "text": "Term" }] },
    { "t": "_def_body",  "children": [{ "t": "text", "text": "Definition one" }] },
    { "t": "_def_body",  "children": [{ "t": "text", "text": "Definition two" }] }
  ]
}
```

---

### `hr`

```markdown
---
```

```json
{ "t": "hr" }
```

---

### `math_block`

```markdown
$$
\int_0^\infty e^{-x} dx = 1
$$
```

```json
{ "t": "math_block", "src": "\\int_0^\\infty e^{-x} dx = 1\n" }
```

Fields: `src` (raw LaTeX string, including whitespace as emitted by the parser).

---

### `html_block`

```markdown
<div class="callout">
Custom HTML block.
</div>
```

```json
{ "t": "html_block", "html": "<div class=\"callout\">\nCustom HTML block.\n</div>\n" }
```

Fields: `html` (raw HTML string).

---

### `footnote_def`

```markdown
[^1]: Footnote body text here.
```

```json
{
  "t": "footnote_def",
  "label": "1",
  "children": [{ "t": "paragraph", "children": [...] }]
}
```

---

## Inline nodes

Inline nodes appear inside a parent's `children` array.

---

### `text`

Plain text content.

```json
{ "t": "text", "text": "Hello, world!" }
```

---

### `em`

```markdown
*italic* or _italic_
```

```json
{ "t": "em", "children": [{ "t": "text", "text": "italic" }] }
```

---

### `strong`

```markdown
**bold** or __bold__
```

```json
{ "t": "strong", "children": [{ "t": "text", "text": "bold" }] }
```

---

### `del`

```markdown
~~strikethrough~~
```

```json
{ "t": "del", "children": [{ "t": "text", "text": "strikethrough" }] }
```

---

### `sup`

```markdown
^superscript^
```

```json
{ "t": "sup", "children": [{ "t": "text", "text": "superscript" }] }
```

---

### `sub`

```markdown
~subscript~
```

> Note: `~` is subscript when `ENABLE_SUBSCRIPT` is on (enabled by default).
> Use `~~double~~ ` for strikethrough instead.

```json
{ "t": "sub", "children": [{ "t": "text", "text": "subscript" }] }
```

---

### `code_span`

```markdown
`inline code`
```

```json
{ "t": "code_span", "text": "inline code" }
```

---

### `math_inline`

```markdown
$E = mc^2$
```

```json
{ "t": "math_inline", "src": "E = mc^2" }
```

---

### `link`

```markdown
[text](https://example.com "title")
```

```json
{
  "t": "link",
  "href": "https://example.com",
  "title": "title",
  "children": [{ "t": "text", "text": "text" }]
}
```

With extended attributes:

```markdown
[datasheet](./rf.pdf){download=true class=doc-link}
```

```json
{
  "t": "link",
  "href": "./rf.pdf",
  "title": "",
  "attrs": { "download": "true", "class": "doc-link" },
  "children": [{ "t": "text", "text": "datasheet" }]
}
```

Fields: `href`, `title`, optional `attrs`, `children` (inline, the link label text).

---

### `image`

```markdown
![alt text](./image.png "caption")
```

```json
{
  "t": "image",
  "src": "./image.png",
  "title": "caption",
  "children": [{ "t": "text", "text": "alt text" }]
}
```

With extended attributes:

```markdown
![Mixer chain](./mixer.png){width=480 class=diagram}
```

```json
{
  "t": "image",
  "src": "./mixer.png",
  "title": "",
  "attrs": { "width": "480", "class": "diagram" },
  "children": [{ "t": "text", "text": "Mixer chain" }]
}
```

Fields: `src`, `title`, optional `attrs`, `children` (inline, the alt text nodes).

---

### `widget`

MarkPlus inline extension for custom components.

```markdown
:[LO]{tooltip text="Local oscillator"}
:[beta]{badge tone=amber}
:[gain stage]{glossary id=gain-stage}
```

```json
{ "t": "widget", "name": "tooltip", "text": "LO", "attrs": { "text": "Local oscillator" } }
{ "t": "widget", "name": "badge",   "text": "beta", "attrs": { "tone": "amber" } }
{ "t": "widget", "name": "glossary","text": "gain stage", "attrs": { "id": "gain-stage" } }
```

Syntax: `:[visible text]{name key=value key2="quoted value" flag}`

- First token in `{...}` = `name`
- `key=value` → string attr
- `key="quoted value"` → string attr (quotes stripped)
- bare `flag``true` bool attr

Fields: `name`, `text`, `attrs`.

---

### `footnote_ref`

```markdown
See the appendix[^1].
```

```json
{ "t": "footnote_ref", "label": "1" }
```

---

### `task_marker`

Emitted as the first inline child of a task-list item paragraph.

```markdown
- [x] done
- [ ] todo
```

```json
{ "t": "task_marker", "checked": true }
{ "t": "task_marker", "checked": false }
```

---

### `soft_break`

A line break that is not a hard break (no trailing spaces or `\`).

```json
{ "t": "soft_break" }
```

---

### `hard_break`

Two trailing spaces or a backslash before a newline.

```markdown
line one\
line two
```

```json
{ "t": "hard_break" }
```

---

### `raw_html`

An inline HTML tag not interpretable as a block.

```markdown
Text with <em>inline HTML</em> tag.
```

```json
{ "t": "raw_html", "html": "<em>" }
```

---

## SiteAsset wire format

The `SiteAsset` produced by `parse_document()` and serialised to `note.json`:

```json
{
  "schema": 1,
  "meta": {
    "title": "RFSoC Mixer Design Notes",
    "category": "hardware",
    "tags": ["rfsoc", "dsp"],
    "date": "2026-05-30",
    "draft": false
  },
  "ast": [ ... block nodes ... ]
}
```

- `schema` — integer, bumped on breaking AST shape changes. Current: **1**.
- `meta``null` if no frontmatter; otherwise the YAML document deserialised into a JSON value tree.
- `ast` — array of block nodes as described in this document.

Renderers should guard on `schema`:

```js
if (site.schema !== 1) throw new Error(`Unsupported AST schema ${site.schema}`);
```