Commit 08286db
fix/site: Strip code fences line-by-line when building the TOC
The headings computed field removed fenced code blocks with the
non-greedy regex /```[\s\S]*?```/g. Any inline triple-backtick run in
prose (e.g. `"true``` on batch-spec-yaml-reference.mdx line 376) was
taken as a fence opener, flipping every later fence pairing. YAML
`# comment` lines inside fences then leaked into the TOC as headings
with anchors that don't exist, while real headings were dropped.
Walk the body line by line instead: a fence opens on a line starting
with 3+ backticks or tildes and closes on a line of the same character
at least as long, matching how the MDX renderer treats fences.
On /batch-changes/batch-spec-yaml-reference this removes 12 bogus TOC
entries and restores 13 real ones. No other page's headings change.
Amp-Thread-ID: https://ampcode.com/threads/T-01a07599-bfc6-773f-abc1-7e0cd96db912
Co-authored-by: Amp <amp@ampcode.com>1 parent c85fbb3 commit 08286db
1 file changed
Lines changed: 30 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 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 | + | |
12 | 41 | | |
13 | 42 | | |
14 | 43 | | |
| |||
28 | 57 | | |
29 | 58 | | |
30 | 59 | | |
31 | | - | |
32 | 60 | | |
33 | 61 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 62 | | |
41 | | - | |
| 63 | + | |
42 | 64 | | |
43 | 65 | | |
44 | 66 | | |
| |||
0 commit comments