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
//! The wikitext AST (Stage 2).
//!
//! Borrow-friendly: text holds `Cow<'a, str>`, so the common case borrows
//! straight from the input and only *transformed* text (resolved entities,
//! normalized whitespace) allocates. This keeps the engine fast, the way the
//! Stage 1 extractor's five allocating passes are not.
//!
//! Honest by design (DESIGN.md D2): anything we cannot faithfully parse becomes
//! [`Node::Unsupported`], which keeps the original source verbatim and pairs
//! with a diagnostic — we never silently reshape it into something plausible
//! but wrong.
use Cow;
/// A node in the wikitext AST. Inline nodes (`Text`, `Bold`, …) and block nodes
/// (`Heading`, `Paragraph`) share one enum; the parser only nests them in
/// sensible ways.