@sakura-ui/sakura-ui 0.5.2 → 0.5.4

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 (26) hide show
  1. package/package.json +2 -2
  2. package/packages/forms/.turbo/turbo-build.log +2 -2
  3. package/packages/helper/.turbo/turbo-build.log +1 -1
  4. package/packages/markdown/.turbo/turbo-build.log +3 -3
  5. package/packages/markdown/dist/index.cjs.js +1 -1
  6. package/packages/markdown/dist/index.es.js +155 -149
  7. package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -1
  8. package/packages/markdown/dist/types/decorate.d.ts +2 -5
  9. package/packages/markdown/dist/types/decorate.d.ts.map +1 -1
  10. package/packages/markdown/dist/types/marked/attributes.d.ts +4 -7
  11. package/packages/markdown/dist/types/marked/attributes.d.ts.map +1 -1
  12. package/packages/markdown/dist/types/marked/registry.d.ts.map +1 -1
  13. package/packages/markdown/dist/types/marked/renderer.d.ts +4 -6
  14. package/packages/markdown/dist/types/marked/renderer.d.ts.map +1 -1
  15. package/packages/markdown/dist/types/marked/tokenizer.d.ts.map +1 -1
  16. package/packages/markdown/package.json +1 -1
  17. package/packages/markdown/src/components/Markdown.tsx +18 -4
  18. package/packages/markdown/src/decorate.ts +3 -8
  19. package/packages/markdown/src/marked/attributes.ts +4 -7
  20. package/packages/markdown/src/marked/directives/card.ts +2 -2
  21. package/packages/markdown/src/marked/html.ts +3 -3
  22. package/packages/markdown/src/marked/registry.ts +2 -5
  23. package/packages/markdown/src/marked/renderer.ts +4 -6
  24. package/packages/markdown/src/marked/tokenizer.ts +5 -7
  25. package/packages/markdown/tests/__snapshots__/Markdown.test.tsx.snap +50 -55
  26. package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/components/Markdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,KAAK,WAAW,EAA6B,MAAM,WAAW,CAAA;AASvE,UAAU,QAAQ;IAChB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB;AAED,eAAO,MAAM,eAAe,GAAI,WAAW,QAAQ,sBAelD,CAAA;AAED,yBAAiB,QAAQ,CAAC;IACxB,UAAiB,KAAK;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,oDAAoD;QACpD,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,0DAA0D;QAC1D,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,QAAQ,EAAE,MAAM,CAAA;KACjB;CACF;AAED,eAAO,MAAM,QAAQ,GAAI,4DAMtB,QAAQ,CAAC,KAAK,sBAoChB,CAAA"}
1
+ {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/components/Markdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,KAAK,WAAW,EAA6B,MAAM,WAAW,CAAA;AASvE,UAAU,QAAQ;IAChB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB;AAED,eAAO,MAAM,eAAe,GAAI,WAAW,QAAQ,sBAelD,CAAA;AAED,yBAAiB,QAAQ,CAAC;IACxB,UAAiB,KAAK;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,oDAAoD;QACpD,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,0DAA0D;QAC1D,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,QAAQ,EAAE,MAAM,CAAA;KACjB;CACF;AAED,eAAO,MAAM,QAAQ,GAAI,4DAMtB,QAAQ,CAAC,KAAK,sBAkDhB,CAAA"}
@@ -1,11 +1,8 @@
1
1
  /**
2
2
  * Applies the look of the design system to the finished document.
3
3
  *
4
- * This runs over the sanitised DOM rather than inside the markdown renderer so
5
- * that a table written as raw HTML 56 of the guide's documents do is styled
6
- * the same as one written with pipes. The pipeline this replaces had the same
7
- * property, because rehype-raw turned the raw HTML into real nodes before the
8
- * tag to component mapping ran.
4
+ * Runs over the sanitised DOM rather than inside the markdown renderer, so that
5
+ * a table written as raw HTML is styled the same as one written with pipes.
9
6
  */
10
7
  export type HeadingItem = {
11
8
  id?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"decorate.d.ts","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAsDD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB,CAAA;AAID,eAAO,MAAM,QAAQ,GACnB,MAAM,gBAAgB,GAAG,OAAO,EAChC,UAAU,QAAQ,EAClB,SAAS,eAAe,KACvB,cA2EF,CAAA"}
1
+ {"version":3,"file":"decorate.d.ts","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAsDD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB,CAAA;AAID,eAAO,MAAM,QAAQ,GACnB,MAAM,gBAAgB,GAAG,OAAO,EAChC,UAAU,QAAQ,EAClB,SAAS,eAAe,KACvB,cAyEF,CAAA"}
@@ -2,14 +2,11 @@ export type Attrs = Record<string, string>;
2
2
  /**
3
3
  * Where `{#name}` is kept, apart from anything written as `key=value`.
4
4
  *
5
- * A sigil says something about the element itself and means the same on every
6
- * directive; an attribute is the directive's own, and each reads the ones it
7
- * knows. Keeping them in one place would let a directive that wanted an
8
- * attribute called `id` take the anchor's place, which is how the video on a
9
- * youtube embed came to be called `id` and stayed that way.
10
- *
5
+ * A sigil describes the element and means the same on every directive; an
6
+ * attribute belongs to whichever directive reads it. Held apart so that a
7
+ * directive wanting an attribute called `id` cannot take the anchor's place.
11
8
  * A key beginning with `#` cannot be written as `key=value`, since an attribute
12
- * name has to start with a letter, so there is nowhere for the two to meet.
9
+ * name has to start with a letter.
13
10
  */
14
11
  export declare const ANCHOR = "#id";
15
12
  /** Parses the inside of `{...}`: `key=value key2="値 2" #id .cls` */
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/marked/attributes.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,oEAAoE;AACpE,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,GAAG,IAAI,KAAG,KAkBhD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EACX,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,OAAO,MAAM,KACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAkBnC,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,QAAQ,GACnB,KAAK,MAAM,EACX,GAAG,MAAM,KACR;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAcnD,CAAA"}
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/marked/attributes.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE1C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,oEAAoE;AACpE,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,GAAG,IAAI,KAAG,KAkBhD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EACX,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,OAAO,MAAM,KACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAkBnC,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,QAAQ,GACnB,KAAK,MAAM,EACX,GAAG,MAAM,KACR;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAcnD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/marked/registry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,cAAc,CAAA;AACpC,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,IAAI,SAAS,CAAA;AAE1B,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,GAAG,OAAO,IAAI,GAAG,OAAO,IAAI,CAAA;AAyBxE,+EAA+E;AAC/E,eAAO,MAAM,OAAO,QAAiC,CAAA;AAErD,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,KAAG,OACmB,CAAA"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/marked/registry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,cAAc,CAAA;AACpC,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,IAAI,SAAS,CAAA;AAE1B,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,GAAG,OAAO,IAAI,GAAG,OAAO,IAAI,CAAA;AAsBxE,+EAA+E;AAC/E,eAAO,MAAM,OAAO,QAAiC,CAAA;AAErD,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,KAAG,OACmB,CAAA"}
@@ -1,13 +1,11 @@
1
1
  import type { DirectiveToken } from './tokenizer';
2
2
  import { type Parser, type RendererOptions } from './directives';
3
3
  /**
4
- * Builds what a directive renderer is given, then hands the token to the one
5
- * that knows it. The renderers themselves live in `directives/`, a file to a
6
- * feature: `card.ts` holds the card and everything written inside one, because
7
- * a title has to know whether the card gave it an href.
4
+ * Builds the context, then hands the token to the renderer that knows its name.
5
+ * The renderers live in `directives/`, a file to a feature, so that a card and
6
+ * everything written inside one stay together.
8
7
  *
9
- * A name with no renderer falls through to its own children, which is what a
10
- * directive the registry allows but nobody has drawn yet looks like.
8
+ * A name with no renderer falls through to its own children.
11
9
  */
12
10
  export declare function directiveRenderer(this: {
13
11
  parser: Parser;
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/marked/renderer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,eAAe,EACrB,MAAM,cAAc,CAAA;AAErB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EACxB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,eAAe,GACvB,MAAM,CAyBR;AAED,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/marked/renderer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,eAAe,EACrB,MAAM,cAAc,CAAA;AAErB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EACxB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,eAAe,GACvB,MAAM,CAyBR;AAED,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../../src/marked/tokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,cAAc,CAAA;AACnD,OAAO,EAAa,KAAK,aAAa,EAAuB,MAAM,YAAY,CAAA;AAE/E,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,OAAO;IACpD,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,aAAa,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,4EAA4E;IAC5E,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AA4BD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAGjD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAGlD,CAAA;AA+CD,wBAAgB,cAAc,CAC5B,IAAI,EAAE;IACJ,KAAK,EAAE;QACL,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAE,CAAA;QACrC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,CAAA;KAC/C,CAAA;CACF,EACD,GAAG,EAAE,MAAM,GACV,cAAc,GAAG,SAAS,CAsC5B;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE;IAAE,KAAK,EAAE;QAAE,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAE,CAAA;KAAE,CAAA;CAAE,EAC3D,GAAG,EAAE,MAAM,GACV,cAAc,GAAG,SAAS,CAiB5B"}
1
+ {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../../src/marked/tokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,cAAc,CAAA;AACnD,OAAO,EAAa,KAAK,aAAa,EAAuB,MAAM,YAAY,CAAA;AAE/E,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,OAAO;IACpD,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,aAAa,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,4EAA4E;IAC5E,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AA4BD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAGjD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAGlD,CAAA;AA6CD,wBAAgB,cAAc,CAC5B,IAAI,EAAE;IACJ,KAAK,EAAE;QACL,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAE,CAAA;QACrC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,CAAA;KAC/C,CAAA;CACF,EACD,GAAG,EAAE,MAAM,GACV,cAAc,GAAG,SAAS,CAsC5B;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE;IAAE,KAAK,EAAE;QAAE,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,EAAE,CAAA;KAAE,CAAA;CAAE,EAC3D,GAAG,EAAE,MAAM,GACV,cAAc,GAAG,SAAS,CAiB5B"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sakura-ui/markdown",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "markdown"
@@ -1,4 +1,4 @@
1
- import { H2, Link, Ul } from '@sakura-ui/core'
1
+ import { Link, Ul } from '@sakura-ui/core'
2
2
  import React from 'react'
3
3
  import { type HeadingItem, render, type RenderResult } from '../render'
4
4
 
@@ -74,14 +74,28 @@ export const Markdown = ({
74
74
  <div className="py-8 flex flex-col gap-8">
75
75
  {showToc && headings.length > 0 && (
76
76
  <nav className="rounded-3xl p-10 bg-yellow-50">
77
- <H2 className="pt-0">{tocTitle}</H2>
77
+ {/*
78
+ The label on a box, not a heading in the document, so it does not
79
+ use core's H2 and its heading size and spacing.
80
+ */}
81
+ <h2 className="mb-4 font-bold text-h-xs-m sm:text-h-xs">
82
+ {tocTitle}
83
+ </h2>
78
84
  <Ul>
79
85
  <TableOfContents items={headings} />
80
86
  </Ul>
81
87
  </nav>
82
88
  )}
83
- {/* The markup is sanitised in src/sanitize.ts before it gets here. */}
84
- <div dangerouslySetInnerHTML={{ __html: html }} />
89
+ {/*
90
+ The document's blocks are children of this element, not of the wrapper,
91
+ so the space between them is set here.
92
+
93
+ The markup is sanitised in src/sanitize.ts before it gets here.
94
+ */}
95
+ <div
96
+ className="flex flex-col gap-8"
97
+ dangerouslySetInnerHTML={{ __html: html }}
98
+ />
85
99
  </div>
86
100
  )
87
101
  }
@@ -5,11 +5,8 @@ import { classNames } from './marked/html'
5
5
  /**
6
6
  * Applies the look of the design system to the finished document.
7
7
  *
8
- * This runs over the sanitised DOM rather than inside the markdown renderer so
9
- * that a table written as raw HTML 56 of the guide's documents do is styled
10
- * the same as one written with pipes. The pipeline this replaces had the same
11
- * property, because rehype-raw turned the raw HTML into real nodes before the
12
- * tag to component mapping ran.
8
+ * Runs over the sanitised DOM rather than inside the markdown renderer, so that
9
+ * a table written as raw HTML is styled the same as one written with pipes.
13
10
  */
14
11
 
15
12
  export type HeadingItem = {
@@ -113,9 +110,7 @@ export const decorate = (
113
110
  const tag = element.tagName.toLowerCase()
114
111
 
115
112
  // One id, generated once, for headings from markdown and from raw HTML
116
- // alike. The pipeline this replaces generated them in two passes that
117
- // disagreed whenever a heading held an image, raw HTML or a directive, and
118
- // the table of contents then linked to anchors that were not there.
113
+ // alike, so the table of contents and the body cannot disagree.
119
114
  if (HEADINGS.has(tag)) {
120
115
  const text = element.textContent ?? ''
121
116
  const asked = element.getAttribute('id')
@@ -6,14 +6,11 @@ export type Attrs = Record<string, string>
6
6
  /**
7
7
  * Where `{#name}` is kept, apart from anything written as `key=value`.
8
8
  *
9
- * A sigil says something about the element itself and means the same on every
10
- * directive; an attribute is the directive's own, and each reads the ones it
11
- * knows. Keeping them in one place would let a directive that wanted an
12
- * attribute called `id` take the anchor's place, which is how the video on a
13
- * youtube embed came to be called `id` and stayed that way.
14
- *
9
+ * A sigil describes the element and means the same on every directive; an
10
+ * attribute belongs to whichever directive reads it. Held apart so that a
11
+ * directive wanting an attribute called `id` cannot take the anchor's place.
15
12
  * A key beginning with `#` cannot be written as `key=value`, since an attribute
16
- * name has to start with a letter, so there is nowhere for the two to meet.
13
+ * name has to start with a letter.
17
14
  */
18
15
  export const ANCHOR = '#id'
19
16
 
@@ -12,8 +12,8 @@ const iconHtml = (name: string, altText: string): string =>
12
12
 
13
13
  export const cardRenderers: Record<string, DirectiveRenderer> = {
14
14
  card: ({ token, attrs, root, body, nl }) => {
15
- // The tokenizer withholds linked from a card with no title, which has no
16
- // link to give and so must not look as though it had one.
15
+ // Set by the tokenizer, and only when the card has a title to put the
16
+ // link on. A card without one must not look as though it were clickable.
17
17
  const isLink = Boolean(token.linked)
18
18
  const cls = classNames(
19
19
  styles.cardStyle,
@@ -31,9 +31,9 @@ export const cleanUrl = (href: string | undefined): string | undefined => {
31
31
  if (href == null || href === '') return undefined
32
32
  const trimmed = stripControl(String(href)).trim()
33
33
  if (/^(?:javascript|vbscript|file):/i.test(trimmed)) return undefined
34
- // Images written as data: used to be kept here and dropped nowhere, since
35
- // DOMPurify allows the scheme on an img whatever ALLOWED_URI_REGEXP says. The
36
- // content has no use for it, so both this and the sanitiser refuse it now.
34
+ // Refused here and in the sanitiser both: DOMPurify allows the scheme on an
35
+ // img whatever ALLOWED_URI_REGEXP says, so this is the only place a directive
36
+ // writing one is turned back.
37
37
  if (/^data:/i.test(trimmed)) return undefined
38
38
  return trimmed
39
39
  }
@@ -6,11 +6,8 @@ export type DirectiveKind = typeof CONTAINER | typeof LEAF | typeof TEXT
6
6
 
7
7
  /**
8
8
  * The whitelist. A name that is not here is not a directive, and the text
9
- * carrying it is left alone.
10
- *
11
- * The remark pipeline this replaces turned any name into a tag of the same
12
- * name, so ordinary prose lost characters: "HH:MM" rendered as "HH", and
13
- * "chat:write" as "chat".
9
+ * carrying it is left alone — which is what keeps "HH:MM" and "chat:write"
10
+ * intact in the prose.
14
11
  */
15
12
  const STATIC: Record<string, DirectiveKind[]> = {
16
13
  card: [CONTAINER],
@@ -10,13 +10,11 @@ import {
10
10
  } from './directives'
11
11
 
12
12
  /**
13
- * Builds what a directive renderer is given, then hands the token to the one
14
- * that knows it. The renderers themselves live in `directives/`, a file to a
15
- * feature: `card.ts` holds the card and everything written inside one, because
16
- * a title has to know whether the card gave it an href.
13
+ * Builds the context, then hands the token to the renderer that knows its name.
14
+ * The renderers live in `directives/`, a file to a feature, so that a card and
15
+ * everything written inside one stay together.
17
16
  *
18
- * A name with no renderer falls through to its own children, which is what a
19
- * directive the registry allows but nobody has drawn yet looks like.
17
+ * A name with no renderer falls through to its own children.
20
18
  */
21
19
  export function directiveRenderer(
22
20
  this: { parser: Parser },
@@ -60,14 +60,12 @@ export const inlineStart = (src: string): number | undefined => {
60
60
  }
61
61
 
62
62
  /**
63
- * A grid of cards is a list. The cards are things of one kind, and how many
64
- * there are is part of what the page says; a grid holding anything else, or
65
- * cards and something else together, is a layout — prose beside a figure is not
66
- * two of something. Nothing is written to ask for this, the way nothing is
67
- * written to ask a run of "- " for a <ul>.
63
+ * A grid of cards is a list: the cards are things of one kind, and how many
64
+ * there are is part of what the page says. A grid holding anything else, or
65
+ * cards mixed with something else, is a layout.
68
66
  *
69
- * Marked here rather than worked out while rendering, because by then the
70
- * children have become one string and the boundaries between them are gone.
67
+ * Marked here rather than while rendering, because by then the children are one
68
+ * string with no boundaries between them.
71
69
  */
72
70
  const markCardList = (token: DirectiveToken): void => {
73
71
  if (!/^grid-cols-\d+$/.test(token.name)) return