@tiaforge-ui/sinter-markdown 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +18 -13
  2. package/docs/markdown.md +9 -9
  3. package/docs/recipes/article-with-comments.html +3 -3
  4. package/llms.txt +4 -4
  5. package/package.json +2 -2
  6. package/sinter/components/internal/md-block.html +2 -2
  7. package/sinter/components/internal/md-blockquote.html +2 -2
  8. package/sinter/components/internal/md-break.html +1 -1
  9. package/sinter/components/internal/md-code.html +2 -2
  10. package/sinter/components/internal/md-delete.html +2 -2
  11. package/sinter/components/internal/md-details.html +2 -2
  12. package/sinter/components/internal/md-emphasis.html +2 -2
  13. package/sinter/components/internal/md-heading.html +2 -2
  14. package/sinter/components/internal/md-image.html +2 -2
  15. package/sinter/components/internal/md-inline-code.html +2 -2
  16. package/sinter/components/internal/md-kbd.html +2 -2
  17. package/sinter/components/internal/md-link.html +2 -2
  18. package/sinter/components/internal/md-list-item.html +2 -2
  19. package/sinter/components/internal/md-list.html +2 -2
  20. package/sinter/components/internal/md-mark.html +2 -2
  21. package/sinter/components/internal/md-paragraph.html +2 -2
  22. package/sinter/components/internal/md-phrasing.html +2 -2
  23. package/sinter/components/internal/md-strong.html +2 -2
  24. package/sinter/components/internal/md-sub.html +2 -2
  25. package/sinter/components/internal/md-sup.html +2 -2
  26. package/sinter/components/internal/md-table.html +2 -2
  27. package/sinter/components/internal/md-thematic-break.html +1 -1
  28. package/sinter/components/md-doc.html +3 -3
  29. package/sinter/components/md-inline.html +3 -3
  30. package/sinter/parser.js +320 -643
package/README.md CHANGED
@@ -8,7 +8,7 @@ with slots.
8
8
  ```html
9
9
  <sn-resource name="post" src="file:./post.md"></sn-resource>
10
10
  <main data-sn-let="{ doc: md.parse(post.body) }">
11
- <md-doc data-sn-prop="{ doc }"></md-doc>
11
+ <md-doc data-sn-with="{ doc }"></md-doc>
12
12
  </main>
13
13
  ```
14
14
 
@@ -27,7 +27,7 @@ npm install @tiaforge-ui/sinter-markdown
27
27
 
28
28
  ```js
29
29
  // vite.config.js: the package is a component library
30
- sinter({ components: ['@tiaforge-ui/sinter-markdown'] })
30
+ sinter({ libraries: ['@tiaforge-ui/sinter-markdown'] })
31
31
  ```
32
32
 
33
33
  ```ts
@@ -114,7 +114,7 @@ docs/ the docs page and the recipe
114
114
  owns: no app component and no other library may use it.
115
115
  - **The contract is in the public files.** `md-doc.html` and `md-inline.html` declare the slots an app
116
116
  fills (`heading: Slot<{ node: Heading }>`, …); the internal components place them
117
- (`<slot name="heading" data-sn-prop="{ node }">`) without declaring them, as [tree
117
+ (`<slot name="heading" data-sn-with="{ node }">`) without declaring them, as [tree
118
118
  slots](https://github.com/tiaforge/sinter/blob/main/docs/components.md#tree-slots). Adding a slot
119
119
  later is additive; renaming or removing one breaks apps.
120
120
  - **Roots.** A component's root renders at most one element. A heading is an if chain over its depth,
@@ -178,7 +178,7 @@ docs/ the docs page and the recipe
178
178
 
179
179
  `parser.js` is markdown-it (CommonMark, GFM tables and `~~strikethrough~~`) with GFM's autolinks
180
180
  (`scripts/autolink.js`), configured for `md.parse` and bundled into one file by `scripts/build-parser.mjs`:
181
- 21.8 kB minified and gzipped (19.5 kB brotli). It returns markdown-it's tokens, and `parse.ts` builds the
181
+ 20.1 kB minified and gzipped (17.9 kB brotli). It returns markdown-it's tokens, and `parse.ts` builds the
182
182
  tree from them in one pass, task lists and the options included: there is no intermediate tree (an mdast
183
183
  before the library's own, and a walk over it).
184
184
 
@@ -188,9 +188,11 @@ before the library's own, and a walk over it).
188
188
  specifies gives the same tree as micromark did, except a code span's line endings, which are spaces,
189
189
  as CommonMark renders them.
190
190
  - **What `md.parse` never runs is left out**, so the bundle holds markdown-it's parsers and rules and
191
- no more: its renderer, the typographer's rules (`typographer` is off) and its linkify are
192
- `scripts/unused.js`; mdurl (`scripts/mdurl.js`) and punycode (`scripts/punycode.js`) are left out
193
- because the tree keeps a link's destination as written, so the parser normalizes no URL; uc.micro's
191
+ no more: `scripts/parser-entry.js` drives the parsers itself rather than through `new MarkdownIt()`,
192
+ whose class brings the presets, the renderer, the plugin API and the default link normalizers (with
193
+ punycode); the typographer's rules (`typographer` is off) and its linkify are `scripts/unused.js`;
194
+ mdurl (`scripts/mdurl.js`) is left out because the tree keeps a link's destination as written, so the
195
+ parser normalizes no URL; uc.micro's
194
196
  tables are two regexes (`scripts/uc-micro.js`: emphasis needs Unicode punctuation and symbols, `\p{P}`
195
197
  and `\p{S}`). The parser was 34.5 kB with them. `test/parse.test.ts` checks which of markdown-it's
196
198
  modules are in it.
@@ -206,9 +208,12 @@ before the library's own, and a walk over it).
206
208
  takes under 0.1 s).
207
209
  - **Entities decode from a table** (`character-entities`, through `scripts/entities.js`), never through
208
210
  the DOM, so the parser works under Trusted Types (`require-trusted-types-for 'script'`). It is the
209
- table micromark used, packed by `scripts/build-parser.mjs`: sorted by code point, each entry its
210
- distance from the one before, about 7.5 kB gzip where the table as an object is 11.5 and
211
- markdown-it's own (`entities`, a packed trie) 21. It is unpacked once, when the parser loads.
211
+ table micromark used, packed by `scripts/build-parser.mjs`: the names that share a value grouped, the
212
+ groups sorted by code point, each its distance from the one before, about 7.3 kB gzip where the table
213
+ as an object is 11.5 and markdown-it's own (`entities`, a packed trie) 21. The names alone gzip to
214
+ 6.6 kB, so the code points cost under 0.7; generating the regular families instead (`Afr`…`zscr`,
215
+ the Cyrillic `…cy`, the accented Latin letters) would save under 1 kB before the rules and their
216
+ exceptions. It is unpacked once, when the parser loads.
212
217
  - sinter's build-time check follows one module that uses no browser global, so `md.parse` folds over
213
218
  a `file:` resource.
214
219
 
@@ -229,12 +234,12 @@ A library has no pages, and sinter checks a component through the pages that use
229
234
  are pages that use the public components with the cases the library supports: an article from a
230
235
  file, every slot filled, comments from an API. `npx sinter check` in this folder takes them as its
231
236
  pages (there is no Vite config with pages of its own), configures the package as a library of
232
- `sinter({ components })`, compiles and type-checks them, and checks the library's rules: every declared
237
+ `sinter({ libraries })`, compiles and type-checks them, and checks the library's rules: every declared
233
238
  slot is placed somewhere (`SN331`), `<sn-component use>` takes a map (`SN312`), internal components are
234
239
  used only inside the library (`SN339`). Each app's build checks the same rules again.
235
240
 
236
- `vite.config.ts` points the check at `fixtures/sinter.helpers.ts` and `fixtures/sinter.types.ts`, which
237
- are what an app would write: the package re-exported by its own name (`export * as md from
241
+ The check reads the modules beside the fixture pages, at their fixed names, `fixtures/sinter.helpers.ts` and
242
+ `fixtures/sinter.types.ts`, which are what an app would write: the package re-exported by its own name (`export * as md from
238
243
  '@tiaforge-ui/sinter-markdown'`, which works because the package has `exports`).
239
244
 
240
245
  ## Checking and testing
package/docs/markdown.md CHANGED
@@ -9,7 +9,7 @@ changed with slots.
9
9
  ```html
10
10
  <sn-resource name="post" src="file:./post.md"></sn-resource>
11
11
  <main data-sn-let="{ doc: md.parse(post.body) }">
12
- <md-doc data-sn-prop="{ doc }"></md-doc>
12
+ <md-doc data-sn-with="{ doc }"></md-doc>
13
13
  </main>
14
14
  ```
15
15
 
@@ -31,7 +31,7 @@ import { defineConfig } from 'vite';
31
31
  import sinter from '@tiaforge-ui/sinter/vite';
32
32
 
33
33
  export default defineConfig({
34
- plugins: [sinter({ components: ['@tiaforge-ui/sinter-markdown'] })],
34
+ plugins: [sinter({ libraries: ['@tiaforge-ui/sinter-markdown'] })],
35
35
  });
36
36
  ```
37
37
 
@@ -52,12 +52,12 @@ export type { Root, Heading, Link, TocEntry } from '@tiaforge-ui/sinter-markdown
52
52
  | A file: `src="file:./post.md"` | at build time | the article as plain HTML, no JavaScript ([static pages](https://github.com/tiaforge/sinter/blob/main/docs/static-pages.md)) |
53
53
  | A string from an API, in a `data-sn-let` | in the browser, once per source and options (md.parse keeps its trees) | the parser with the page |
54
54
  | The same, with the parser lazy | in the browser, once the parser has loaded | the parser in a chunk of its own, loaded when a let first needs it |
55
- | A tree from an API you control (`md.parse` run on the server, `<md-doc data-sn-prop="{ doc: article.doc }">`) | on the server: the API sends the tree instead of the markdown | no parser ([Performance](#performance)); the parse moves to the server, or to wherever the API stores the tree |
55
+ | A tree from an API you control (`md.parse` run on the server, `<md-doc data-sn-with="{ doc: article.doc }">`) | on the server: the API sends the tree instead of the markdown | no parser ([Performance](#performance)); the parse moves to the server, or to wherever the API stores the tree |
56
56
 
57
57
  To make the parser lazy, list the package in `lazy`:
58
58
 
59
59
  ```js
60
- sinter({ components: ['@tiaforge-ui/sinter-markdown'], lazy: ['@tiaforge-ui/sinter-markdown'] })
60
+ sinter({ libraries: ['@tiaforge-ui/sinter-markdown'], lazy: ['@tiaforge-ui/sinter-markdown'] })
61
61
  ```
62
62
 
63
63
  A let that calls `md.parse` is then `undefined` until the parser has arrived, and its arrival renders
@@ -71,7 +71,7 @@ file: over twice sinter's early budget (`SN523`). For a page whose main content
71
71
  better trade: on RealWorld's article through sinter-axum (Lighthouse mobile), the early file was 30.5 kB gzip, the
72
72
  first paint did not move, and the LCP was the first paint, 1,359 ms, against 2,127 ms with the body rendered when
73
73
  the page module mounts. The parser is then downloaded twice (the early file and the page module). Raise the
74
- budget for it (`sinter({ earlyBudget })`), as the RealWorld example does ([its
74
+ budget for it (`sinter({ firstPaint: { budget } })`), as the RealWorld example does ([its
75
75
  README](https://github.com/tiaforge/sinter/blob/main/examples/realworld/README.md)); or keep the body out with
76
76
  `data-sn-early="off"` on the `<md-doc>`, and keep what follows the body out of the layout until it renders.
77
77
  Measure first: a page whose markdown is not its main content pays the early file for nothing. Markdown from an
@@ -138,13 +138,13 @@ is frozen, at every depth, and shared: to change one, change a copy (`structured
138
138
 
139
139
  | | Renders | Root |
140
140
  | --- | --- | --- |
141
- | `<md-doc data-sn-prop="{ doc }">` | the blocks of a document | `<div class="md">` |
142
- | `<md-inline data-sn-prop="{ doc }">` | one line: the content of the paragraphs and headings, without their elements, with a space between two of them (a title, a label); other blocks are left out | `<span class="md">` |
141
+ | `<md-doc data-sn-with="{ doc }">` | the blocks of a document | `<div class="md">` |
142
+ | `<md-inline data-sn-with="{ doc }">` | one line: the content of the paragraphs and headings, without their elements, with a space between two of them (a title, a label); other blocks are left out | `<span class="md">` |
143
143
 
144
144
  - `doc` is optional: with none, the root is empty. Its root is always there, so the tag may carry a
145
145
  `class`, attributes and handlers.
146
146
  - `<md-inline>` is phrasing content, a `<span>` with only phrasing content inside, so it is valid in
147
- a heading, a label, a link or a paragraph: `<h1><md-inline data-sn-prop="{ doc: md.parse(post.title)
147
+ a heading, a label, a link or a paragraph: `<h1><md-inline data-sn-with="{ doc: md.parse(post.title)
148
148
  }"></md-inline></h1>`. Parse a title with the options that fit a line; a list or a code block in it
149
149
  is not rendered.
150
150
  - The HTML is what a markdown renderer writes, with no wrapper of its own but one: `<h2 id="md-…">`,
@@ -178,7 +178,7 @@ in the tree, in a list item, a quote or a table cell. Each passes the node as `$
178
178
  | `table` | `Table` (`align`, `children`) | `<div class="md-table"><table>…</table></div>` |
179
179
 
180
180
  ```html
181
- <md-doc data-sn-prop="{ doc }">
181
+ <md-doc data-sn-with="{ doc }">
182
182
  <!-- readers' links -->
183
183
  <a slot="link" rel="nofollow ugc" data-sn-attr="{ href: $slot.node.url }"><slot></slot></a>
184
184
  <!-- a heading with a link to itself: an if chain over the depth -->
@@ -9,20 +9,20 @@
9
9
  <sn-resource name="comments" src="/api/post/comments" key="id"></sn-resource>
10
10
 
11
11
  <article id="post" data-sn-let="{ doc: md.parse(post?.body) }">
12
- <h1><md-inline data-sn-prop="{ doc: md.parse(post?.title) }"></md-inline></h1>
12
+ <h1><md-inline data-sn-with="{ doc: md.parse(post?.title) }"></md-inline></h1>
13
13
  <nav aria-label="Contents">
14
14
  <ol>
15
15
  <template data-sn-for="h in md.headings(doc)"><li><a data-sn-attr="{ href: '#' + h.id }" data-sn-text="h.text"></a></li></template>
16
16
  </ol>
17
17
  </nav>
18
- <md-doc id="body" data-sn-prop="{ doc }"></md-doc>
18
+ <md-doc id="body" data-sn-with="{ doc }"></md-doc>
19
19
  </article>
20
20
 
21
21
  <section id="comments" aria-label="Comments">
22
22
  <template data-sn-for="c in comments" data-sn-key="c.id">
23
23
  <article class="comment" data-sn-let="{ doc: md.parse(c.body, { headings: 'strong', images: 'link', html: 'text' }) }">
24
24
  <h3 data-sn-text="c.author"></h3>
25
- <md-doc data-sn-prop="{ doc }"><a slot="link" rel="nofollow ugc" data-sn-attr="{ href: $slot.node.url }"><slot></slot></a></md-doc>
25
+ <md-doc data-sn-with="{ doc }"><a slot="link" rel="nofollow ugc" data-sn-attr="{ href: $slot.node.url }"><slot></slot></a></md-doc>
26
26
  </article>
27
27
  </template>
28
28
  </section>
package/llms.txt CHANGED
@@ -4,16 +4,16 @@
4
4
 
5
5
  ## Setup
6
6
 
7
- - vite.config: `sinter({ components: ['@tiaforge-ui/sinter-markdown'] })`; to load the parser on demand, also `lazy: ['@tiaforge-ui/sinter-markdown']`.
7
+ - vite.config: `sinter({ libraries: ['@tiaforge-ui/sinter-markdown'] })`; to load the parser on demand, also `lazy: ['@tiaforge-ui/sinter-markdown']`.
8
8
  - src/sinter.helpers.ts: `export * as md from '@tiaforge-ui/sinter-markdown';`
9
9
  - src/sinter.types.ts: `export type { Root, Heading, Link, Image, Code, Table, TocEntry } from '@tiaforge-ui/sinter-markdown';`
10
10
 
11
11
  ## Pages
12
12
 
13
- - From a file (static, no JavaScript): `<sn-resource name="post" src="file:./post.md"></sn-resource><main data-sn-let="{ doc: md.parse(post, { base: '/posts/' }) }"><md-doc data-sn-prop="{ doc }"></md-doc></main>`. `base` (a folder from the project root) makes relative image and link URLs root paths, so local images are optimized.
14
- - From an API: `<article data-sn-let="{ doc: md.parse(post?.body) }"><md-doc data-sn-prop="{ doc }"></md-doc></article>`. md.parse keeps its trees (frozen, shared): one parse per source and options, whatever reads it. With the parser lazy, `doc` is undefined until it loads; <md-doc> renders an empty root meanwhile.
13
+ - From a file (static, no JavaScript): `<sn-resource name="post" src="file:./post.md"></sn-resource><main data-sn-let="{ doc: md.parse(post, { base: '/posts/' }) }"><md-doc data-sn-with="{ doc }"></md-doc></main>`. `base` (a folder from the project root) makes relative image and link URLs root paths, so local images are optimized.
14
+ - From an API: `<article data-sn-let="{ doc: md.parse(post?.body) }"><md-doc data-sn-with="{ doc }"></md-doc></article>`. md.parse keeps its trees (frozen, shared): one parse per source and options, whatever reads it. With the parser lazy, `doc` is undefined until it loads; <md-doc> renders an empty root meanwhile.
15
15
  - Readers' content: `md.parse(c.body, { headings: 'strong', images: 'link', html: 'text' })`, and a link fill with `rel="nofollow ugc"`.
16
- - One line (a title, a label): `<h1><md-inline data-sn-prop="{ doc: md.parse(post.title) }"></md-inline></h1>`: a `<span class="md">` with the paragraphs' and headings' content (phrasing content only; other blocks left out).
16
+ - One line (a title, a label): `<h1><md-inline data-sn-with="{ doc: md.parse(post.title) }"></md-inline></h1>`: a `<span class="md">` with the paragraphs' and headings' content (phrasing content only; other blocks left out).
17
17
 
18
18
  ## md.parse options
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiaforge-ui/sinter-markdown",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Markdown for sinter: a parser to mdast that folds at build time, and md-* components with slots for the nodes an app changes.",
5
5
  "license": "MIT",
6
6
  "author": "Tia Heinrich",
@@ -43,7 +43,7 @@
43
43
  "test": "vitest run"
44
44
  },
45
45
  "peerDependencies": {
46
- "@tiaforge-ui/sinter": ">=0.20.0 <1"
46
+ "@tiaforge-ui/sinter": ">=0.21.0 <1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@tiaforge-ui/sinter": "file:../..",
@@ -2,6 +2,6 @@
2
2
  One block, by its type: the only place block content is dispatched. To add a block type, add it to
3
3
  Block in sinter.types.ts, write its component in this folder, and add it to this map.
4
4
  -->
5
- <template data-sn-component="{ node: Block }">
6
- <sn-component use="{ paragraph: 'md-paragraph', heading: 'md-heading', thematicBreak: 'md-thematic-break', blockquote: 'md-blockquote', list: 'md-list', code: 'md-code', table: 'md-table', details: 'md-details' }[node.type]" data-sn-prop="{ node }"></sn-component>
5
+ <template data-sn-props="{ node: Block }">
6
+ <sn-component use="{ paragraph: 'md-paragraph', heading: 'md-heading', thematicBreak: 'md-thematic-break', blockquote: 'md-blockquote', list: 'md-list', code: 'md-code', table: 'md-table', details: 'md-details' }[node.type]" data-sn-with="{ node }"></sn-component>
7
7
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Blockquote }">
2
- <slot name="blockquote" data-sn-prop="{ node }"><blockquote><template data-sn-for="b in node.children"><md-block data-sn-prop="{ node: b }"></md-block></template></blockquote></slot>
1
+ <template data-sn-props="{ node: Blockquote }">
2
+ <slot name="blockquote" data-sn-with="{ node }"><blockquote><template data-sn-for="b in node.children"><md-block data-sn-with="{ node: b }"></md-block></template></blockquote></slot>
3
3
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Break }">
1
+ <template data-sn-props="{ node: Break }">
2
2
  <br>
3
3
  </template>
@@ -1,4 +1,4 @@
1
1
  <!-- A code block. A fill can highlight it: at build time, with a helper over the constant code. -->
2
- <template data-sn-component="{ node: Code }">
3
- <slot name="code" data-sn-prop="{ node }"><pre><code data-sn-attr="{ class: node.lang ? 'language-' + node.lang : null }" data-sn-text="node.value"></code></pre></slot>
2
+ <template data-sn-props="{ node: Code }">
3
+ <slot name="code" data-sn-with="{ node }"><pre><code data-sn-attr="{ class: node.lang ? 'language-' + node.lang : null }" data-sn-text="node.value"></code></pre></slot>
4
4
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Delete }">
2
- <del><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></del>
1
+ <template data-sn-props="{ node: Delete }">
2
+ <del><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></del>
3
3
  </template>
@@ -1,4 +1,4 @@
1
1
  <!-- <details> with its <summary>, kept from raw HTML under md.parse's html: 'allow'. -->
2
- <template data-sn-component="{ node: Details }">
3
- <details data-sn-attr="{ open: node.open }"><template data-sn-if="node.summary.length"><summary><template data-sn-for="n in node.summary"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></summary></template><template data-sn-for="b in node.children"><md-block data-sn-prop="{ node: b }"></md-block></template></details>
2
+ <template data-sn-props="{ node: Details }">
3
+ <details data-sn-attr="{ open: node.open }"><template data-sn-if="node.summary.length"><summary><template data-sn-for="n in node.summary"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></summary></template><template data-sn-for="b in node.children"><md-block data-sn-with="{ node: b }"></md-block></template></details>
4
4
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Emphasis }">
2
- <em><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></em>
1
+ <template data-sn-props="{ node: Emphasis }">
2
+ <em><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></em>
3
3
  </template>
@@ -1,4 +1,4 @@
1
1
  <!-- A heading: its root is the `heading` slot, whose default is an if chain over the depth. -->
2
- <template data-sn-component="{ node: Heading }">
3
- <slot name="heading" data-sn-prop="{ node }"><template data-sn-if="node.depth === 1"><h1 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></h1></template><template data-sn-else><template data-sn-if="node.depth === 2"><h2 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></h2></template><template data-sn-else><template data-sn-if="node.depth === 3"><h3 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></h3></template><template data-sn-else><template data-sn-if="node.depth === 4"><h4 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></h4></template><template data-sn-else><template data-sn-if="node.depth === 5"><h5 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></h5></template><template data-sn-else><h6 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></h6></template></template></template></template></template></slot>
2
+ <template data-sn-props="{ node: Heading }">
3
+ <slot name="heading" data-sn-with="{ node }"><template data-sn-if="node.depth === 1"><h1 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></h1></template><template data-sn-else><template data-sn-if="node.depth === 2"><h2 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></h2></template><template data-sn-else><template data-sn-if="node.depth === 3"><h3 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></h3></template><template data-sn-else><template data-sn-if="node.depth === 4"><h4 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></h4></template><template data-sn-else><template data-sn-if="node.depth === 5"><h5 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></h5></template><template data-sn-else><h6 data-sn-attr="{ id: 'md-' + node.slug }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></h6></template></template></template></template></template></slot>
4
4
  </template>
@@ -4,6 +4,6 @@
4
4
  send it through the app's resizing service (`sinter({ images: { remote } })`), since user content may
5
5
  name any image. An app that wants it resized fills the `image` slot with its own <img>.
6
6
  -->
7
- <template data-sn-component="{ node: Image }">
8
- <slot name="image" data-sn-prop="{ node }"><img data-sn-attr="{ src: node.url, alt: node.alt, title: node.title, srcset: null }"></slot>
7
+ <template data-sn-props="{ node: Image }">
8
+ <slot name="image" data-sn-with="{ node }"><img data-sn-attr="{ src: node.url, alt: node.alt, title: node.title, srcset: null }"></slot>
9
9
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: InlineCode }">
2
- <slot name="inlineCode" data-sn-prop="{ node }"><code data-sn-text="node.value"></code></slot>
1
+ <template data-sn-props="{ node: InlineCode }">
2
+ <slot name="inlineCode" data-sn-with="{ node }"><code data-sn-text="node.value"></code></slot>
3
3
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Kbd }">
2
- <kbd><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></kbd>
1
+ <template data-sn-props="{ node: Kbd }">
2
+ <kbd><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></kbd>
3
3
  </template>
@@ -1,4 +1,4 @@
1
1
  <!-- A link: its URL is an attribute binding, so sinter refuses javascript: and other unsafe schemes. -->
2
- <template data-sn-component="{ node: Link }">
3
- <slot name="link" data-sn-prop="{ node }"><a data-sn-attr="{ href: node.url, title: node.title }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></a></slot>
2
+ <template data-sn-props="{ node: Link }">
3
+ <slot name="link" data-sn-with="{ node }"><a data-sn-attr="{ href: node.url, title: node.title }"><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></a></slot>
4
4
  </template>
@@ -1,4 +1,4 @@
1
1
  <!-- An item: a task's checkbox, then its blocks; in a tight list a paragraph is its content alone, without <p>. -->
2
- <template data-sn-component="{ node: ListItem; tight: boolean }">
3
- <li data-sn-class="{ 'task-list-item': node.checked !== null }"><template data-sn-if="node.checked !== null"><input type="checkbox" disabled data-sn-attr="{ checked: node.checked }"></template><template data-sn-for="b in node.children"><template data-sn-if="tight && b.type === 'paragraph'"><template data-sn-for="n in b.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></template><template data-sn-else><md-block data-sn-prop="{ node: b }"></md-block></template></template></li>
2
+ <template data-sn-props="{ node: ListItem; tight: boolean }">
3
+ <li data-sn-class="{ 'task-list-item': node.checked !== null }"><template data-sn-if="node.checked !== null"><input type="checkbox" disabled data-sn-attr="{ checked: node.checked }"></template><template data-sn-for="b in node.children"><template data-sn-if="tight && b.type === 'paragraph'"><template data-sn-for="n in b.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></template><template data-sn-else><md-block data-sn-with="{ node: b }"></md-block></template></template></li>
4
4
  </template>
@@ -1,4 +1,4 @@
1
1
  <!-- A list: an if chain over `ordered`. Each item knows whether the list is tight (no <p> in its items). -->
2
- <template data-sn-component="{ node: List }">
3
- <template data-sn-if="node.ordered"><ol data-sn-attr="{ start: node.start === 1 ? null : node.start }"><template data-sn-for="i in node.children"><md-list-item data-sn-prop="{ node: i, tight: !node.spread }"></md-list-item></template></ol></template><template data-sn-else><ul><template data-sn-for="i in node.children"><md-list-item data-sn-prop="{ node: i, tight: !node.spread }"></md-list-item></template></ul></template>
2
+ <template data-sn-props="{ node: List }">
3
+ <template data-sn-if="node.ordered"><ol data-sn-attr="{ start: node.start === 1 ? null : node.start }"><template data-sn-for="i in node.children"><md-list-item data-sn-with="{ node: i, tight: !node.spread }"></md-list-item></template></ol></template><template data-sn-else><ul><template data-sn-for="i in node.children"><md-list-item data-sn-with="{ node: i, tight: !node.spread }"></md-list-item></template></ul></template>
4
4
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Mark }">
2
- <mark><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></mark>
1
+ <template data-sn-props="{ node: Mark }">
2
+ <mark><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></mark>
3
3
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Paragraph }">
2
- <p><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></p>
1
+ <template data-sn-props="{ node: Paragraph }">
2
+ <p><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></p>
3
3
  </template>
@@ -4,6 +4,6 @@
4
4
  writes them itself and passes every other node here. To add an inline type, add it to Inline in
5
5
  sinter.types.ts, write its component in this folder, and add it to this map.
6
6
  -->
7
- <template data-sn-component="{ node: Phrasing }">
8
- <sn-component use="{ emphasis: 'md-emphasis', strong: 'md-strong', delete: 'md-delete', inlineCode: 'md-inline-code', break: 'md-break', link: 'md-link', image: 'md-image', kbd: 'md-kbd', sub: 'md-sub', sup: 'md-sup', mark: 'md-mark' }[node.type]" data-sn-prop="{ node }"></sn-component>
7
+ <template data-sn-props="{ node: Phrasing }">
8
+ <sn-component use="{ emphasis: 'md-emphasis', strong: 'md-strong', delete: 'md-delete', inlineCode: 'md-inline-code', break: 'md-break', link: 'md-link', image: 'md-image', kbd: 'md-kbd', sub: 'md-sub', sup: 'md-sup', mark: 'md-mark' }[node.type]" data-sn-with="{ node }"></sn-component>
9
9
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Strong }">
2
- <strong><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></strong>
1
+ <template data-sn-props="{ node: Strong }">
2
+ <strong><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></strong>
3
3
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Sub }">
2
- <sub><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></sub>
1
+ <template data-sn-props="{ node: Sub }">
2
+ <sub><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></sub>
3
3
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: Sup }">
2
- <sup><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></sup>
1
+ <template data-sn-props="{ node: Sup }">
2
+ <sup><template data-sn-for="n in node.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></sup>
3
3
  </template>
@@ -4,6 +4,6 @@
4
4
  <slot> written inside a <table> out of it, so a fill places the whole table (<slot></slot> in a
5
5
  <div class="scroll">), or renders its own.
6
6
  -->
7
- <template data-sn-component="{ node: Table }">
8
- <slot name="table" data-sn-prop="{ node }"><div class="md-table"><table><thead><template data-sn-for="r in node.children.slice(0, 1)"><tr><template data-sn-for="(c, k) in r.children"><th data-sn-attr="{ align: node.align[k] }"><template data-sn-for="n in c.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></th></template></tr></template></thead><template data-sn-if="node.children.length > 1"><tbody><template data-sn-for="r in node.children.slice(1)"><tr><template data-sn-for="(c, k) in r.children"><td data-sn-attr="{ align: node.align[k] }"><template data-sn-for="n in c.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></td></template></tr></template></tbody></template></table></div></slot>
7
+ <template data-sn-props="{ node: Table }">
8
+ <slot name="table" data-sn-with="{ node }"><div class="md-table"><table><thead><template data-sn-for="r in node.children.slice(0, 1)"><tr><template data-sn-for="(c, k) in r.children"><th data-sn-attr="{ align: node.align[k] }"><template data-sn-for="n in c.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></th></template></tr></template></thead><template data-sn-if="node.children.length > 1"><tbody><template data-sn-for="r in node.children.slice(1)"><tr><template data-sn-for="(c, k) in r.children"><td data-sn-attr="{ align: node.align[k] }"><template data-sn-for="n in c.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></td></template></tr></template></tbody></template></table></div></slot>
9
9
  </template>
@@ -1,3 +1,3 @@
1
- <template data-sn-component="{ node: ThematicBreak }">
1
+ <template data-sn-props="{ node: ThematicBreak }">
2
2
  <hr>
3
3
  </template>
@@ -1,10 +1,10 @@
1
1
  <!--
2
2
  md-doc: a parsed document, block content. Public.
3
- <md-doc data-sn-prop="{ doc }"></md-doc>, `doc` from md.parse (or an API that sends the tree).
3
+ <md-doc data-sn-with="{ doc }"></md-doc>, `doc` from md.parse (or an API that sends the tree).
4
4
  Its root is a plain element, so the tag may carry an id or a class; with no doc it is empty.
5
5
  The slots below are the library's whole contract: a fill changes how that kind of node renders,
6
6
  wherever it is in the tree.
7
7
  -->
8
- <template data-sn-component="{ doc?: Root | null; heading: Slot<{ node: Heading }>; link: Slot<{ node: Link }>; image: Slot<{ node: Image }>; code: Slot<{ node: Code }>; inlineCode: Slot<{ node: InlineCode }>; blockquote: Slot<{ node: Blockquote }>; table: Slot<{ node: Table }> }">
9
- <div class="md"><template data-sn-for="b in doc ? doc.children : []"><md-block data-sn-prop="{ node: b }"></md-block></template></div>
8
+ <template data-sn-props="{ doc?: Root | null; heading: Slot<{ node: Heading }>; link: Slot<{ node: Link }>; image: Slot<{ node: Image }>; code: Slot<{ node: Code }>; inlineCode: Slot<{ node: InlineCode }>; blockquote: Slot<{ node: Blockquote }>; table: Slot<{ node: Table }> }">
9
+ <div class="md"><template data-sn-for="b in doc ? doc.children : []"><md-block data-sn-with="{ node: b }"></md-block></template></div>
10
10
  </template>
@@ -1,11 +1,11 @@
1
1
  <!--
2
2
  md-inline: a parsed line, phrasing content. Public.
3
- <h1><md-inline data-sn-prop="{ doc: md.parse(post.title) }"></md-inline></h1>: the content of the
3
+ <h1><md-inline data-sn-with="{ doc: md.parse(post.title) }"></md-inline></h1>: the content of the
4
4
  document's paragraphs and headings, without their elements, one space between two of them; other
5
5
  blocks (a list, a code block) are left out. Its root is a <span> with only phrasing content inside,
6
6
  so it is valid in a heading, a label, a link or a paragraph. It places links, images and inline code, so those
7
7
  are the slots it declares.
8
8
  -->
9
- <template data-sn-component="{ doc?: Root | null; link: Slot<{ node: Link }>; image: Slot<{ node: Image }>; inlineCode: Slot<{ node: InlineCode }> }">
10
- <span class="md"><template data-sn-for="(b, i) in doc ? doc.children.filter((x) => x.type === 'paragraph' || x.type === 'heading') : []"><template data-sn-if="i > 0"><template data-sn-text="' '"></template></template><template data-sn-for="n in b.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-prop="{ node: n }"></md-phrasing></template></template></template></span>
9
+ <template data-sn-props="{ doc?: Root | null; link: Slot<{ node: Link }>; image: Slot<{ node: Image }>; inlineCode: Slot<{ node: InlineCode }> }">
10
+ <span class="md"><template data-sn-for="(b, i) in doc ? doc.children.filter((x) => x.type === 'paragraph' || x.type === 'heading') : []"><template data-sn-if="i > 0"><template data-sn-text="' '"></template></template><template data-sn-for="n in b.children"><template data-sn-if="n.type === 'text'"><template data-sn-text="n.value"></template></template><template data-sn-else><md-phrasing data-sn-with="{ node: n }"></md-phrasing></template></template></template></span>
11
11
  </template>