AtlatestRepositorysigil-markdown
1---
2title: Representative Folio Note
3tags: slate, performance, markdown
4created: 2026-07-20
5status: draft
6---
7
8# Slate Rendering Pipeline
9
10This is a **representative** folio note that exercises *most* of the block and
11inline constructs the parser handles. It mixes `inline code`, [links](https://example.com),
12and **bold with _nested italic_** so the inline PEG grammar sees real work.
14## Background
16The reading-view render path in Slate calls `markdown->sxml` on every note. When a
17whole folio is rendered by default, this runs hundreds of times, so per-render cost
18matters. See the [design doc](https://sigil.org/docs/markdown) for context.
20Some paragraphs are long and wrap across multiple source lines to stress the
21paragraph accumulation loop, which joins lines with a single space before running
22the inline parser over the *entire* joined string. This is where a lot of the
23plain-text scanning happens, because every character passes through the text-run
24negative-lookahead gauntlet in the inline grammar.
26### Inline stress
28Here we have `code spans`, **strong**, __also strong__, *em*, _also em_, a
29[named link](https://codeberg.org/sigil), an ![image](img/logo.png), and an
30escaped \* asterisk. Mixing them: **bold `code` inside** and *italic [link](x)*.
32## Lists
34- First unordered item with some **bold** text
35- Second item with `inline code` and a [link](https://example.com)
36- Third item that is long enough to wrap and contains *emphasis* plus more words
37 to push the inline scanner along a longer run of plain characters here
38- Fourth item
401. Ordered item one
412. Ordered item two with `code`
423. Ordered item three
44## Code
46```scheme
47(define (markdown->sxml text)
48 (let* ((lines (string->lines text))
49 (blocks (parse-blocks lines)))
50 (map block->sxml blocks)))
51```
53 indented code block
54 with two lines
56## Quote
58> A blockquote line with **bold** and a [link](https://example.com).
59> Second quoted line continuing the same quote block.
61## Table
63| Feature | Native | Wasm | Notes |
64|:-------------|:------:|------:|:------------------------------|
65| Headings | fast | ok | cheap PEG match per line |
66| Inline code | medium | slow | per-char lookahead in grammar |
67| Tables | medium | slow | many `parse-inline` calls |
68| Paragraphs | slow | slow | long joined text runs |
70## Horizontal rule
72---
74## Closing
76A final paragraph with a trailing [reference link](https://example.com) and some
77`inline code` to make sure the tail of the document still parses cleanly and the
78inline grammar terminates without backtracking blowups on plain text runs.