comark-ui 0.0.0-stage → 0.7.1
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.
- package/LICENSE +69 -0
- package/README.md +70 -2
- package/dist/client.d.mts +12 -0
- package/dist/client.mjs +26 -0
- package/dist/editor-BAdok66p.mjs +835 -0
- package/dist/editor-CNivEuMH.d.mts +131 -0
- package/dist/editor-vue.d.mts +57 -0
- package/dist/editor-vue.mjs +85 -0
- package/dist/editor.d.mts +2 -0
- package/dist/editor.mjs +1 -0
- package/dist/html.d.mts +7 -0
- package/dist/html.mjs +90 -0
- package/dist/index-B0YvApci.d.mts +173 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/nuxt-ui.d.mts +17 -0
- package/dist/nuxt-ui.mjs +488 -0
- package/dist/react.d.mts +8 -0
- package/dist/react.mjs +83 -0
- package/dist/skills/comark-ui/SKILL.md +138 -0
- package/dist/skills/comark-ui/agents/openai.yaml +3 -0
- package/dist/skills/comark-ui/references/annotate.md +65 -0
- package/dist/skills/comark-ui/references/badge.md +52 -0
- package/dist/skills/comark-ui/references/cards.md +57 -0
- package/dist/skills/comark-ui/references/carousel.md +31 -0
- package/dist/skills/comark-ui/references/cast.md +48 -0
- package/dist/skills/comark-ui/references/charts.md +80 -0
- package/dist/skills/comark-ui/references/chat.md +25 -0
- package/dist/skills/comark-ui/references/chips.md +33 -0
- package/dist/skills/comark-ui/references/cjk.md +23 -0
- package/dist/skills/comark-ui/references/code-notes.md +34 -0
- package/dist/skills/comark-ui/references/code.md +84 -0
- package/dist/skills/comark-ui/references/colors.md +33 -0
- package/dist/skills/comark-ui/references/critic.md +30 -0
- package/dist/skills/comark-ui/references/deflist.md +38 -0
- package/dist/skills/comark-ui/references/details.md +49 -0
- package/dist/skills/comark-ui/references/diagrams.md +45 -0
- package/dist/skills/comark-ui/references/diff.md +43 -0
- package/dist/skills/comark-ui/references/embed.md +40 -0
- package/dist/skills/comark-ui/references/fields.md +48 -0
- package/dist/skills/comark-ui/references/figure.md +25 -0
- package/dist/skills/comark-ui/references/file-tree.md +42 -0
- package/dist/skills/comark-ui/references/footnotes.md +26 -0
- package/dist/skills/comark-ui/references/github.md +44 -0
- package/dist/skills/comark-ui/references/icon.md +28 -0
- package/dist/skills/comark-ui/references/include.md +44 -0
- package/dist/skills/comark-ui/references/keys.md +28 -0
- package/dist/skills/comark-ui/references/links.md +43 -0
- package/dist/skills/comark-ui/references/lint.md +96 -0
- package/dist/skills/comark-ui/references/magic-move.md +34 -0
- package/dist/skills/comark-ui/references/mark.md +22 -0
- package/dist/skills/comark-ui/references/math.md +25 -0
- package/dist/skills/comark-ui/references/media.md +29 -0
- package/dist/skills/comark-ui/references/metrics.md +34 -0
- package/dist/skills/comark-ui/references/outline.md +36 -0
- package/dist/skills/comark-ui/references/properties.md +32 -0
- package/dist/skills/comark-ui/references/qr.md +20 -0
- package/dist/skills/comark-ui/references/quiz.md +45 -0
- package/dist/skills/comark-ui/references/reading-time.md +32 -0
- package/dist/skills/comark-ui/references/sources.md +24 -0
- package/dist/skills/comark-ui/references/steps.md +34 -0
- package/dist/skills/comark-ui/references/table.md +48 -0
- package/dist/skills/comark-ui/references/tabs.md +46 -0
- package/dist/skills/comark-ui/references/tests.md +59 -0
- package/dist/skills/comark-ui/references/ui.md +54 -0
- package/dist/skills/comark-ui/references/xref.md +48 -0
- package/dist/skills/comark-ui/references/zoom.md +35 -0
- package/dist/src-DROB05U6.mjs +119 -0
- package/dist/svelte/Typeset.svelte +7 -0
- package/dist/svelte/index.d.ts +9 -0
- package/dist/svelte/index.js +84 -0
- package/dist/typeset-css-DPB0S1bV.mjs +202 -0
- package/dist/typeset-css-DdOGL7WF.d.mts +10 -0
- package/dist/vue.d.mts +7 -0
- package/dist/vue.mjs +86 -0
- package/package.json +170 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Tables from CSV, TSV, and JSON
|
|
2
|
+
|
|
3
|
+
comark-table turns CSV, TSV, or JSON from a fence or a file into a plain HTML table with a Copy button, which pastes as cells in a spreadsheet, and a menu that copies it as Markdown or CSV. With `sort`, its headers sort the rows. Use it for benchmark results, exports, and any data a tool wrote, so the page shows the numbers the run produced.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
````md
|
|
8
|
+
::table{sort}
|
|
9
|
+
```csv
|
|
10
|
+
Benchmark,Before (ms),After (ms)
|
|
11
|
+
Parse the duck census,"1,204",980
|
|
12
|
+
Render the pond map,88,91
|
|
13
|
+
```
|
|
14
|
+
::
|
|
15
|
+
````
|
|
16
|
+
|
|
17
|
+
Or read the file the run wrote, and leave the block empty:
|
|
18
|
+
|
|
19
|
+
```md
|
|
20
|
+
::table{src="bench/results.csv" sort}
|
|
21
|
+
::
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- A ` ```csv ` or ` ```tsv ` fence turns into a table anywhere, with the Copy button and no sorting. Wrap it in `::table` to set the props below.
|
|
25
|
+
- A ` ```json ` fence stays code unless it sits inside `::table`. It holds an array of objects, one per row. Every key becomes a column, in the order first seen, and a nested value shows as JSON.
|
|
26
|
+
- `src` starts at the document's folder, or at the host's `root` when it starts with `/`. It can't leave `root` or be a URL, and the extension picks the format. The plugin drops content beside `src` and reports it.
|
|
27
|
+
- A Markdown table inside `::table{sort}` or `::table{copy}` gets the Copy button. A `::table` with no props renders its Markdown table plain.
|
|
28
|
+
|
|
29
|
+
| Prop | What it does |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `src` | A `.csv`, `.tsv`, or `.json` file to read. |
|
|
32
|
+
| `format` | `csv`, `tsv`, or `json`, for a file or fence whose extension or language doesn't say. |
|
|
33
|
+
| `sort` | Makes every header a button that sorts the rows, up then down. Numbers sort as numbers. |
|
|
34
|
+
| `copy` | On by default. `copy=false` hides the Copy button and its menu. |
|
|
35
|
+
|
|
36
|
+
CSV follows RFC 4180. A cell in double quotes may hold commas and line breaks, and `""` is a quote inside one. TSV splits at tabs and has no quoting. The first row is the header, and every row needs one cell per column. A column whose cells are all numbers, with commas or a short unit such as `12 ms`, lines up on the right. A fence the plugin can't read stays code, and the plugin says why.
|
|
37
|
+
|
|
38
|
+
## Fit the data to the page
|
|
39
|
+
|
|
40
|
+
- Every row becomes HTML, so trim a large export to the rows the reader needs before you write it. A table wider than the page scrolls sideways in its frame.
|
|
41
|
+
- `src` can't fetch a URL. Download the data next to the document, or paste it in a fence.
|
|
42
|
+
- To number a table with [xref](xref.md), wrap a Markdown table in `::table{#tbl-name caption="..."}` with no other props. A table that comark-table draws loses its `id`, so comark-xref reports every `:ref` to it.
|
|
43
|
+
- To draw the numbers, write a `::chart` around a Markdown table instead, as [charts](charts.md) shows.
|
|
44
|
+
|
|
45
|
+
## Register
|
|
46
|
+
|
|
47
|
+
- In `comark-ui`: on. Fences render, and every `src` reports a missing file until you pass `table: { root: "docs" }` or `{ read }`.
|
|
48
|
+
- Alone: `pnpm add comark @comark/html comark-table`, then `createHtmlRenderer({ plugins: [table({ root: "docs" })], components })` with both from `comark-table/html`. `root` is the folder `src` can't leave, default `.`, the working directory. `base` is the document's folder under it, where relative paths start. `read(path)` returns a file's text, for browsers and edge runtimes. `fences: false` keeps csv and tsv fences as code. `comark-table/vue`, `/react`, and `/svelte` render it too.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Tabs and code groups
|
|
2
|
+
|
|
3
|
+
comark-tabs draws `::tabs` of any Markdown, `::code-group` of code blocks, and a tab per package manager for a code block marked `pm`. Use tabs for versions of one thing where each reader needs only one, such as an operating system, a framework, or a package manager.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
````md
|
|
8
|
+
::code-group{sync="pm"}
|
|
9
|
+
```sh [pnpm]
|
|
10
|
+
pnpm add comark-tabs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```sh [npm]
|
|
14
|
+
npm install comark-tabs
|
|
15
|
+
```
|
|
16
|
+
::
|
|
17
|
+
|
|
18
|
+
::tabs{sync="os"}
|
|
19
|
+
:::tabs-item{label="macOS"}
|
|
20
|
+
Press **⌘K** to find the pigeon data.
|
|
21
|
+
:::
|
|
22
|
+
|
|
23
|
+
:::tabs-item{label="Windows"}
|
|
24
|
+
Press **Ctrl+K** to find the pigeon data.
|
|
25
|
+
:::
|
|
26
|
+
::
|
|
27
|
+
````
|
|
28
|
+
|
|
29
|
+
- `::tabs`: each `:::tabs-item` inside is one tab. Content outside every tab doesn't render, and is reported.
|
|
30
|
+
- `:::tabs-item`: `label` is required and must differ from the other labels in its block, since `sync` matches tabs by label. `icon` draws an Iconify name, such as `lucide:apple`, or an image URL before the label.
|
|
31
|
+
- `::code-group`: only code blocks go inside. Name each one's tab in brackets after its language, as in `sh [pnpm]`, with an optional icon after it, as in `sh [pnpm] icon=logos:pnpm`. The tab replaces the block's own title, and comark-code's `title="pnpm"` names no tab.
|
|
32
|
+
- `sync`, on either block, is a key shared by blocks that switch together. Picking a tab picks the tab with the same label in every block with that key, and the next page that uses the key remembers it.
|
|
33
|
+
- A code block marked `pm`, as in `sh pm`, holds package manager commands in any manager (npm, npx, pnpm, pnpx, yarn, bun, bunx, or deno) and becomes a code group with a tab each for npm, pnpm, yarn, and bun, synced as `pm`. The manager it's written in keeps its commands as written. It reads install, frozen install (`npm ci`), add with `-D`, `-E`, `-O`, `--save-peer`, or `-g`, remove, update, run, `npx`/`dlx`, create, and init. Only commands at the start of a line or after `&&`, `||`, or `;` change. Inside a `::code-group`, `pm` does nothing.
|
|
34
|
+
|
|
35
|
+
## Choose the block
|
|
36
|
+
|
|
37
|
+
- `::code-group` when every tab is one code block, such as one config file per framework. Give every install snippet `sync="pm"`, the key `pm` blocks use, so the reader picks a package manager once.
|
|
38
|
+
- `pm` for package manager commands, so you write them once in the manager you use. A command with no form in a manager, such as `npm install -g` in yarn, or one it doesn't read, such as `npm publish`, leaves those tabs out and is reported. Write that block as a `::code-group{sync="pm"}` by hand.
|
|
39
|
+
- `::tabs` when a tab holds prose, images, or several blocks.
|
|
40
|
+
|
|
41
|
+
Put only alternatives in tabs. Anything every reader needs goes outside them, since a reader sees one tab at a time. For a before and after, use annotate's `::compare` or comark-diff's `::diff`, which show both sides at once.
|
|
42
|
+
|
|
43
|
+
## Register
|
|
44
|
+
|
|
45
|
+
- In `comark-ui`: on, as `tabs`. `tabs: { managers }` sets the tabs a `pm` block gets, in order. The default is `["npm", "pnpm", "yarn", "bun"]`, and `"deno"` can join. `tabs: { icons }` gives each tab without an icon one by its label, such as `{ pnpm: "logos:pnpm" }`. Icons resolve through the preset's `icon` options, from the Iconify API unless its `collections` hold the set.
|
|
46
|
+
- Alone: `pnpm add comark @comark/html comark-tabs`, then `createHtmlRenderer({ plugins: [tabs()], components })` with both from `comark-tabs/html`. `comark-tabs/vue`, `/react`, and `/svelte` (Svelte 5.20 or later) export the same pair for those renderers. It takes `managers`, `icons`, and `iconResolver`, a `createIcons()` from comark-icon to share with `:icon`. List it before Shiki, so Shiki highlights the tabs `pm` adds.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Test results
|
|
2
|
+
|
|
3
|
+
comark-tests reads a JUnit XML report into one line of passed, failed, and skipped counts with the run's duration, and folds each failure under it with its message and stack. Use it when a pull request or a CI summary reports a test run, so the reader sees the run itself.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
````md
|
|
8
|
+
::tests{title="Pond census tests"}
|
|
9
|
+
```xml
|
|
10
|
+
<testsuite name="pond.test.ts" time="0.42">
|
|
11
|
+
<testcase classname="pond.test.ts" name="counts the ducks" time="0.01"/>
|
|
12
|
+
<testcase classname="pond.test.ts" name="counts the geese" time="0.02">
|
|
13
|
+
<failure message="expected 3 to be 4">AssertionError: expected 3 to be 4
|
|
14
|
+
at pond.test.ts:12:20</failure>
|
|
15
|
+
</testcase>
|
|
16
|
+
<testcase classname="pond.test.ts" name="maps the herons"><skipped/></testcase>
|
|
17
|
+
</testsuite>
|
|
18
|
+
```
|
|
19
|
+
::
|
|
20
|
+
````
|
|
21
|
+
|
|
22
|
+
Or read the report from a file, and leave the block empty:
|
|
23
|
+
|
|
24
|
+
```md
|
|
25
|
+
::tests{src="reports/junit.xml" title="CI run"}
|
|
26
|
+
::
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Prop | What it does |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `src` | The JUnit XML file to read. The path starts at the document's folder, or at the host's `root` when it starts with `/`, and it can't leave `root` or be a URL. Without `src`, the block holds one fence with the report. |
|
|
32
|
+
| `title` | Shown before the counts. It also names the results for screen readers, which hear "Test results" without one. |
|
|
33
|
+
|
|
34
|
+
The block shows:
|
|
35
|
+
|
|
36
|
+
- The counts of `<testcase>` elements. A case with `<skipped>` is skipped, one with `<failure>` or `<error>` failed, and the rest passed. Failed and skipped show only when there are any.
|
|
37
|
+
- The duration, from the `time` of `<testsuites>`, else the sum of the suites' times, else the cases', written as `250 ms`, `4.2 s`, or `1 min 21 s`. A report without times shows none.
|
|
38
|
+
- Each failure as a closed disclosure named `classname › name`, with its `message` and its stack in a code block. Failures print open.
|
|
39
|
+
|
|
40
|
+
The root is `<testsuites>` or a single `<testsuite>`. A report with another root renders nothing, and so does malformed XML, which the plugin reports with its line.
|
|
41
|
+
|
|
42
|
+
## Use the run's own report
|
|
43
|
+
|
|
44
|
+
Paste or point at the report the runner wrote, unedited, so the counts are the run's. Most runners write JUnit XML with a flag:
|
|
45
|
+
|
|
46
|
+
| Runner | Command |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| Vitest | `vitest run --reporter=junit --outputFile=junit.xml` |
|
|
49
|
+
| Jest | `jest --reporters=jest-junit` |
|
|
50
|
+
| pytest | `pytest --junitxml=junit.xml` |
|
|
51
|
+
| Go | `go test -v ./... 2>&1 \| go-junit-report > junit.xml` |
|
|
52
|
+
| Playwright | `PLAYWRIGHT_JUNIT_OUTPUT_NAME=junit.xml playwright test --reporter=junit` |
|
|
53
|
+
|
|
54
|
+
When the host reads files, have CI write the report next to the document and point `src` at it. Otherwise paste it into the fence. A long report stays short on the page, since the summary is one line and each failure stays closed until a reader opens it.
|
|
55
|
+
|
|
56
|
+
## Register
|
|
57
|
+
|
|
58
|
+
- In `comark-ui`: on. A pasted report renders, and every `src` reports a missing file until you pass `tests: { root: "." }` or `{ read }`.
|
|
59
|
+
- Alone: `pnpm add comark @comark/html comark-tests`, then `createHtmlRenderer({ plugins: [tests({ root: "." })], components })` with both from `comark-tests/html`. `root` is the folder `src` can't leave, default `.`, the working directory. `base` is the document's folder under it, where relative paths start. `read(path)` returns a file's text, for browsers and edge runtimes. The output needs no script. `comark-tests/vue`, `/react`, and `/svelte` render it too. With comark-code registered, each stack gets a Copy button.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Every plugin in one install
|
|
2
|
+
|
|
3
|
+
comark-ui registers every comark-ui package for one renderer, in the order they need, with one icon resolver shared by `:icon`, cards, details, file trees, tabs, and code actions. Install in SKILL.md shows its basic use. This page covers its options, what it turns on, its other renderers, and how the linter uses it.
|
|
4
|
+
|
|
5
|
+
## Options
|
|
6
|
+
|
|
7
|
+
`comarkUi(options)` returns `{ plugins, components }`. Each key is a package's name without `comark-`, in camelCase, such as `fileTree`, `codeNotes`, or `readingTime`. `false` turns a plugin off along with its components, and an object turns it on with those options. `true` turns on `include` and leaves the others as they are:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
comarkUi({
|
|
11
|
+
zoom: false,
|
|
12
|
+
code: { actions: [{ id: "run", label: "Run" }] },
|
|
13
|
+
github: { callouts: false, references: { repo: "owner/name" } },
|
|
14
|
+
table: { root: "data" },
|
|
15
|
+
include: { root: "content", base: "guide" },
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`github` takes its three plugins by name, `callouts`, `references`, and `html`, and `links` takes `external` and `anchors`. Each package's reference lists its own options. The order stays fixed whatever you pass. `include` runs first, so the others read what it pastes, and `code` and `codeNotes` run last, after every plugin that writes code blocks.
|
|
20
|
+
|
|
21
|
+
## What it turns on
|
|
22
|
+
|
|
23
|
+
- Every plugin except `include`, which reads files from disk. `include: { root, base }` turns it on, or `{ read }` in a browser or an edge runtime. `include: true` reads under the working directory.
|
|
24
|
+
- `cast`, `table`, and `tests` get a reader that finds no file. Inline casts, CSV fences, and pasted JUnit reports render, and a `src` file doesn't load until you pass `{ root }` or `{ read }`. Any other options object replaces that reader too, so the plugin reads under the working directory.
|
|
25
|
+
- Three plugins use the network while parsing: `chips` downloads favicons and avatars, `icon` fetches icon sets from the Iconify API, and `diagrams` sends each diagram's source to `https://kroki.io`. In a browser, pass `chips: { download: false }`, since a browser may not download another site's images. To parse offline, also pass `icon: { fetch: false }` with your icon sets in `collections`, and `diagrams: { draw: false }`. To keep diagram sources private, pass your own Kroki `server`.
|
|
26
|
+
- `icon`'s options apply to every icon the preset draws, in cards, details, file trees, tabs, and code actions too.
|
|
27
|
+
- comark-critic has no component to add its styles, so put `criticCss`, which every entry exports, in the page.
|
|
28
|
+
- The text around the blocks is styled by default, scoped to the element the document renders into, on the same `--comark-*` tokens. Pass `typeset: false` when the site already styles Markdown, such as with Tailwind Typography's `prose`.
|
|
29
|
+
|
|
30
|
+
## Renderers
|
|
31
|
+
|
|
32
|
+
| Renderer | Entry |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `@comark/html` | `comark-ui/html` |
|
|
35
|
+
| `@comark/vue` | `comark-ui/vue` |
|
|
36
|
+
| `@comark/react` | `comark-ui/react` |
|
|
37
|
+
| `@comark/svelte` | `comark-ui/svelte` |
|
|
38
|
+
|
|
39
|
+
The Vue, React, and Svelte entries leave out annotate and diff, which render only to HTML. Screenshots, compares, diffs, and the marks on charts need `comark-ui/html`.
|
|
40
|
+
|
|
41
|
+
To use another renderer, install it in place of `@comark/html`, such as `pnpm add comark @comark/vue comark-ui`, and pass it `plugins` and `components` as you would one package's. The preset needs Vue 3.5, React 18, or Svelte 5.20 or later. Every entry exports the `PresetOptions` type, and `comark-ui` itself exports `preset(renderer, options)`, which builds the same pair from renderer entries you pass.
|
|
42
|
+
|
|
43
|
+
## In the linter
|
|
44
|
+
|
|
45
|
+
comark-linter imports `comark-ui/html` when the project has it, and lints with all its plugins and components, ahead of any comark package installed on its own, so none runs twice. It calls `comarkUi()` with options of its own, so the app's options don't reach it:
|
|
46
|
+
|
|
47
|
+
- It draws no chart or diagram, and downloads no chip image.
|
|
48
|
+
- `::cast`, `::table`, and `::tests` read their `src` files from the working directory.
|
|
49
|
+
- `include` stays off until a lint config adds it, as [include](include.md) says.
|
|
50
|
+
|
|
51
|
+
## Register
|
|
52
|
+
|
|
53
|
+
- In `comark-ui`: this is the preset itself, registered as Install in SKILL.md shows.
|
|
54
|
+
- Alone: each plugin is its own package, registered as its reference says. The preset ships in lockstep with them, so `comark-ui@X` holds every plugin at version `X`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Numbered figures and tables
|
|
2
|
+
|
|
3
|
+
comark-xref numbers labeled images and tables in document order, and turns `:ref{#id}` into a link that reads "Figure 2". Use it when the text refers to its images or tables by number, so the numbers stay right when you add, remove, or reorder them.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
The empty state in :ref{#fig-empty} replaces the spinner in :ref{#fig-loading}, and :ref{#tbl-load} has the load times.
|
|
9
|
+
|
|
10
|
+
{#fig-empty}
|
|
11
|
+
|
|
12
|
+
{#fig-loading}
|
|
13
|
+
|
|
14
|
+
::table{#tbl-load caption="Time to first row, in ms"}
|
|
15
|
+
| Page | Before | After |
|
|
16
|
+
| --- | --: | --: |
|
|
17
|
+
| Correlations | 1840 | 620 |
|
|
18
|
+
::
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- `{#fig-name}` after an image alone in its paragraph makes it a `figure`, captioned "Figure 1: " and its alt text. The plugin doesn't number an image that shares its paragraph with text, and reports it.
|
|
22
|
+
- `::table{#tbl-name caption="..."}` around one Markdown table captions it "Table 1: " and its `caption`. A Markdown table takes no id on its own.
|
|
23
|
+
- A label is `fig-` or `tbl-`, then letters, digits, `_`, or `-`. The plugin numbers figures and tables apart.
|
|
24
|
+
- `:ref{#id}` becomes a link that reads "Figure 1" or "Table 1", to a label above or below it. The plugin drops text in `:ref[...]` and renders a `:ref` to an unknown label as `[id]`. It reports both, and a label used twice.
|
|
25
|
+
|
|
26
|
+
## Label a screenshot
|
|
27
|
+
|
|
28
|
+
The plugin also numbers any other element with a `fig-` id as a figure, such as a `::figure` you caption yourself, and adds no caption to it. It numbers a `::screenshot` or `::compare` too, but their HTML drops the id, so the link leads nowhere. Wrap the screenshot in a `::div` that carries the label:
|
|
29
|
+
|
|
30
|
+
```md
|
|
31
|
+
:ref{#fig-toolbar} shows the toolbar on one row.
|
|
32
|
+
|
|
33
|
+
::div{#fig-toolbar}
|
|
34
|
+
:::screenshot{src="after.png" alt="Filter toolbar on one row"}
|
|
35
|
+
:::
|
|
36
|
+
::
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## With other plugins
|
|
40
|
+
|
|
41
|
+
- Leave the title off a labeled image, since its alt text is the caption. comark-figure, on in `comark-ui`, makes a titled image its own figure first, and xref then reports it as sharing its paragraph.
|
|
42
|
+
- Keep comark-table's `sort`, `copy`, and `src` off a labeled `::table`. With them, comark-table takes the block, drops the label, and reports `caption` as an unknown prop.
|
|
43
|
+
- Write `:ref{#fig-name}` where Pandoc writes `@fig-name`, which comark-chips and comark-github read as a mention.
|
|
44
|
+
|
|
45
|
+
## Register
|
|
46
|
+
|
|
47
|
+
- In `comark-ui`: on in every entry. `xref: { figure: "Abbildung", table: "Tabelle" }` sets the words before the numbers, `"Figure"` and `"Table"` by default.
|
|
48
|
+
- Alone: `pnpm add comark comark-xref`, then `createHtmlRenderer({ plugins: [xref()] })` with `xref` from `comark-xref`. It has no components and no styles, so it works with any renderer. Its output is `figure`, `figcaption`, `caption`, and `a`, with the classes `cxr`, `cxr-label`, and `cxr-ref` for your own rules.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Zoom
|
|
2
|
+
|
|
3
|
+
comark-zoom lets the reader click an image or a `::zoom` block to see it large, and closes it with Escape, Back, or a click around it. Images zoom with no markup. Wrap a table, code block, or diagram in `::zoom` when it's too small to read in place.
|
|
4
|
+
|
|
5
|
+
## Syntax
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
::zoom{title="Deploy retry policy"}
|
|
9
|
+
| Attempt | Wait before it |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| 1 | 1 s |
|
|
12
|
+
| 2 | 4 s |
|
|
13
|
+
| 3 | 16 s |
|
|
14
|
+
::
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- `::zoom` zooms everything inside it as one item. `title` heads the zoomed view. Items with the same `group` page through one zoomed view, with a strip of them below. `#id` and `.class` go on the block.
|
|
18
|
+
- Every content image zooms on its own, with its alt text as the zoomed view's heading. It grows no larger than its file, so give a small image a larger file to open with `{data-zoom-src="dashboard@2x.png"}`.
|
|
19
|
+
- An image inside a link keeps its link and doesn't zoom. Images inside `::zoom`, `::carousel`, `::screenshot`, or `::compare` zoom with their block.
|
|
20
|
+
- `{zoom=false}` keeps an image from zooming, and `{data-zoom}` makes any element zoom on its own.
|
|
21
|
+
|
|
22
|
+
comark-zoom reports no problems, so a misspelled prop such as `titel` is dropped silently and passes the linter. Spell `title` and `group` as written here.
|
|
23
|
+
|
|
24
|
+
## Group or carousel
|
|
25
|
+
|
|
26
|
+
A `group` leaves each item in its place in the text and pages through them only once one is zoomed. Use it for screenshots that sit apart, each next to the paragraph about it. A `::carousel` puts the items in one place with arrows instead. An item hidden when the view opens, such as one in a closed tab, stays out of its group.
|
|
27
|
+
|
|
28
|
+
## In the page
|
|
29
|
+
|
|
30
|
+
The zoomed view fires `comark-zoom:open`, `comark-zoom:change`, and `comark-zoom:close` on the item, and they bubble. The `detail` of `open` and `change` holds the dialog's `header` and `footer`, a `layer` over the zoomed content where a host draws its own pins, and `copyOf(element)` and `originalOf(element)` to map between the page and the zoomed copy. `data-zoom-aside`, a selector, shows a caption beside the zoomed item at its own size, as annotate does with a screenshot's notes.
|
|
31
|
+
|
|
32
|
+
## Register
|
|
33
|
+
|
|
34
|
+
- In `comark-ui`: on, as `zoom`. `zoom: { images: false }` leaves images alone, so only `::zoom` blocks and elements marked `{data-zoom}` zoom.
|
|
35
|
+
- Alone: `pnpm add comark @comark/html comark-zoom`, then `createHtmlRenderer({ plugins: [zoom()], components })` with both from `comark-zoom/html`. `comark-zoom/vue`, `/react`, and `/svelte` export the same pair for those renderers. The plugin adds a node that starts the script, so pass the components even when only images zoom. A page with no renderer calls `start()` from `comark-zoom/client` once. comark-annotate and comark-carousel zoom their own blocks without it, so register `zoom()` for images and `::zoom`.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import cjk from "comark-cjk";
|
|
2
|
+
import critic, { css as criticCss } from "comark-critic";
|
|
3
|
+
import deflist from "comark-deflist";
|
|
4
|
+
import figure from "comark-figure";
|
|
5
|
+
import footnotes from "comark-footnotes";
|
|
6
|
+
import { createIcons } from "comark-icon";
|
|
7
|
+
import include from "comark-include";
|
|
8
|
+
import keys from "comark-keys";
|
|
9
|
+
import readingTime from "comark-reading-time";
|
|
10
|
+
import xref from "comark-xref";
|
|
11
|
+
import { defineComarkPlugin } from "comark";
|
|
12
|
+
//#region src/typeset.ts
|
|
13
|
+
/** The node that adds the styles. The plugin adds one at the end of every document. */
|
|
14
|
+
const TYPESET_TAG = "typeset-styles";
|
|
15
|
+
/** Adds the node that writes the typeset styles at the end of the document. The preset turns it on by default. */
|
|
16
|
+
const typeset = defineComarkPlugin(() => ({
|
|
17
|
+
name: "comark-ui-typeset",
|
|
18
|
+
post(state) {
|
|
19
|
+
state.tree.nodes.push([TYPESET_TAG, {}]);
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/index.ts
|
|
24
|
+
const on = (value, fallback = true) => value === void 0 ? fallback : value !== false;
|
|
25
|
+
const optionsOf = (value) => value === true || value === false ? void 0 : value;
|
|
26
|
+
const noFiles = { read: () => void 0 };
|
|
27
|
+
/** Builds a renderer's preset. Use the one from `comark-ui/html`, `/vue`, `/react`, or `/svelte`. */
|
|
28
|
+
function preset(renderer, options = {}) {
|
|
29
|
+
const plugins = [];
|
|
30
|
+
const components = {};
|
|
31
|
+
const add = (part, value, settings = optionsOf(value)) => {
|
|
32
|
+
if (!part || !on(value)) return;
|
|
33
|
+
plugins.push(part.default(settings));
|
|
34
|
+
Object.assign(components, part.components);
|
|
35
|
+
};
|
|
36
|
+
const parse = (plugin, value) => {
|
|
37
|
+
if (on(value)) plugins.push(plugin(optionsOf(value)));
|
|
38
|
+
};
|
|
39
|
+
const icons = createIcons(optionsOf(options.icon));
|
|
40
|
+
if (on(options.include, false)) plugins.push(include(optionsOf(options.include)));
|
|
41
|
+
add(renderer.annotate, options.annotate);
|
|
42
|
+
add(renderer.carousel, options.carousel);
|
|
43
|
+
add(renderer.cast, options.cast, optionsOf(options.cast) ?? noFiles);
|
|
44
|
+
parse(cjk, options.cjk);
|
|
45
|
+
parse(deflist, options.deflist);
|
|
46
|
+
parse(figure, options.figure);
|
|
47
|
+
parse(critic, options.critic);
|
|
48
|
+
add(renderer.charts, options.charts);
|
|
49
|
+
add(renderer.chips, options.chips);
|
|
50
|
+
add(renderer.colors, options.colors);
|
|
51
|
+
add(renderer.diagrams, options.diagrams);
|
|
52
|
+
add(renderer.mermaid, options.mermaid);
|
|
53
|
+
add(renderer.diff, options.diff);
|
|
54
|
+
add(renderer.embed, options.embed);
|
|
55
|
+
parse(footnotes, options.footnotes);
|
|
56
|
+
if (on(options.github)) {
|
|
57
|
+
const github = optionsOf(options.github) ?? {};
|
|
58
|
+
if (on(github.callouts)) {
|
|
59
|
+
plugins.push(renderer.github.callouts(optionsOf(github.callouts)));
|
|
60
|
+
Object.assign(components, renderer.github.components);
|
|
61
|
+
}
|
|
62
|
+
if (on(github.references)) plugins.push(renderer.github.references(optionsOf(github.references)));
|
|
63
|
+
if (on(github.html)) plugins.push(renderer.github.html());
|
|
64
|
+
}
|
|
65
|
+
add(renderer.icon, options.icon, icons);
|
|
66
|
+
add(renderer.mark, options.mark);
|
|
67
|
+
add(renderer.math, options.math);
|
|
68
|
+
add(renderer.details, options.details, {
|
|
69
|
+
iconResolver: icons,
|
|
70
|
+
...optionsOf(options.details)
|
|
71
|
+
});
|
|
72
|
+
if (on(options.links)) {
|
|
73
|
+
const links = optionsOf(options.links) ?? {};
|
|
74
|
+
if (on(links.external)) plugins.push(renderer.links.external(optionsOf(links.external)));
|
|
75
|
+
if (on(links.anchors)) plugins.push(renderer.links.anchors(optionsOf(links.anchors)));
|
|
76
|
+
if (on(links.external) || on(links.anchors)) Object.assign(components, renderer.links.components);
|
|
77
|
+
}
|
|
78
|
+
add(renderer.fileTree, options.fileTree, {
|
|
79
|
+
iconResolver: icons,
|
|
80
|
+
...optionsOf(options.fileTree)
|
|
81
|
+
});
|
|
82
|
+
add(renderer.fields, options.fields);
|
|
83
|
+
add(renderer.properties, options.properties);
|
|
84
|
+
parse(keys, options.keys);
|
|
85
|
+
add(renderer.badge, options.badge);
|
|
86
|
+
add(renderer.media, options.media);
|
|
87
|
+
add(renderer.metrics, options.metrics);
|
|
88
|
+
add(renderer.table, options.table, optionsOf(options.table) ?? noFiles);
|
|
89
|
+
add(renderer.cards, options.cards, { iconResolver: icons });
|
|
90
|
+
add(renderer.qr, options.qr);
|
|
91
|
+
add(renderer.sources, options.sources);
|
|
92
|
+
add(renderer.steps, options.steps);
|
|
93
|
+
add(renderer.quiz, options.quiz);
|
|
94
|
+
parse(readingTime, options.readingTime);
|
|
95
|
+
add(renderer.tabs, options.tabs, {
|
|
96
|
+
iconResolver: icons,
|
|
97
|
+
...optionsOf(options.tabs)
|
|
98
|
+
});
|
|
99
|
+
add(renderer.magicMove, options.magicMove);
|
|
100
|
+
add(renderer.outline, options.outline);
|
|
101
|
+
parse(xref, options.xref);
|
|
102
|
+
add(renderer.tests, options.tests, optionsOf(options.tests) ?? noFiles);
|
|
103
|
+
add(renderer.zoom, options.zoom);
|
|
104
|
+
add(renderer.code, options.code, {
|
|
105
|
+
iconResolver: icons,
|
|
106
|
+
...optionsOf(options.code)
|
|
107
|
+
});
|
|
108
|
+
add(renderer.codeNotes, options.codeNotes);
|
|
109
|
+
if (on(options.typeset)) {
|
|
110
|
+
plugins.push(typeset());
|
|
111
|
+
components[TYPESET_TAG] = renderer.typeset;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
plugins,
|
|
115
|
+
components
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { typeset as i, preset as n, TYPESET_TAG as r, criticCss as t };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<!-- Writes the typeset styles with the document rather than on mount, so `@scope` styles its root and server renders
|
|
2
|
+
arrive styled. -->
|
|
3
|
+
<script>
|
|
4
|
+
import { typesetCss } from "comark-ui/client";
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{@html `<style data-comark-typeset>${typesetCss}</style>`}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Component } from "svelte";
|
|
2
|
+
import type { Preset, PresetOptions } from "comark-ui";
|
|
3
|
+
|
|
4
|
+
export { criticCss } from "comark-ui";
|
|
5
|
+
export type { PresetOptions } from "comark-ui";
|
|
6
|
+
|
|
7
|
+
/** Every plugin with components for `@comark/svelte`, which leaves out annotate, diff, and quiz. */
|
|
8
|
+
declare const comarkUi: (options?: PresetOptions) => Preset<Component>;
|
|
9
|
+
export default comarkUi;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Every plugin with components for `@comark/svelte`, which leaves out annotate, diff, and quiz.
|
|
2
|
+
import { preset } from "comark-ui";
|
|
3
|
+
import { addMermaidStyles } from "comark-ui/client";
|
|
4
|
+
import * as badge from "comark-badge/svelte";
|
|
5
|
+
import * as cards from "comark-cards/svelte";
|
|
6
|
+
import * as carousel from "comark-carousel/svelte";
|
|
7
|
+
import * as cast from "comark-cast/svelte";
|
|
8
|
+
import * as charts from "comark-charts/svelte";
|
|
9
|
+
import * as chips from "comark-chips/svelte";
|
|
10
|
+
import * as code from "comark-code/svelte";
|
|
11
|
+
import * as codeNotes from "comark-code-notes/svelte";
|
|
12
|
+
import * as colors from "comark-colors/svelte";
|
|
13
|
+
import * as details from "comark-details/svelte";
|
|
14
|
+
import * as diagrams from "comark-diagrams/svelte";
|
|
15
|
+
import * as embed from "comark-embed/svelte";
|
|
16
|
+
import * as fields from "comark-fields/svelte";
|
|
17
|
+
import * as fileTree from "comark-file-tree/svelte";
|
|
18
|
+
import * as github from "comark-github/svelte";
|
|
19
|
+
import * as icon from "comark-icon/svelte";
|
|
20
|
+
import * as links from "comark-links/svelte";
|
|
21
|
+
import * as magicMove from "comark-magic-move/svelte";
|
|
22
|
+
import * as mark from "comark-mark/svelte";
|
|
23
|
+
import * as math from "comark-mathml/svelte";
|
|
24
|
+
import * as media from "comark-media/svelte";
|
|
25
|
+
import pele, { createPeleComponent } from "comark-pele/svelte";
|
|
26
|
+
import * as metrics from "comark-metrics/svelte";
|
|
27
|
+
import * as outline from "comark-outline/svelte";
|
|
28
|
+
import * as properties from "comark-properties/svelte";
|
|
29
|
+
import * as qr from "comark-qr/svelte";
|
|
30
|
+
import * as sources from "comark-sources/svelte";
|
|
31
|
+
import * as steps from "comark-steps/svelte";
|
|
32
|
+
import * as table from "comark-table/svelte";
|
|
33
|
+
import * as tabs from "comark-tabs/svelte";
|
|
34
|
+
import * as tests from "comark-tests/svelte";
|
|
35
|
+
import * as zoom from "comark-zoom/svelte";
|
|
36
|
+
import typeset from "./Typeset.svelte";
|
|
37
|
+
|
|
38
|
+
export { criticCss } from "comark-ui";
|
|
39
|
+
|
|
40
|
+
// Pele calls `onRender` only in the browser, after it draws, so the styles arrive like the other components' do.
|
|
41
|
+
const mermaid = {
|
|
42
|
+
default: pele,
|
|
43
|
+
components: { pele: createPeleComponent({ onRender: addMermaidStyles }) },
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default (options) =>
|
|
47
|
+
preset(
|
|
48
|
+
{
|
|
49
|
+
badge,
|
|
50
|
+
cards,
|
|
51
|
+
carousel,
|
|
52
|
+
cast,
|
|
53
|
+
charts,
|
|
54
|
+
chips,
|
|
55
|
+
code,
|
|
56
|
+
codeNotes,
|
|
57
|
+
colors,
|
|
58
|
+
details,
|
|
59
|
+
diagrams,
|
|
60
|
+
embed,
|
|
61
|
+
fields,
|
|
62
|
+
fileTree,
|
|
63
|
+
github,
|
|
64
|
+
icon,
|
|
65
|
+
links,
|
|
66
|
+
magicMove,
|
|
67
|
+
mark,
|
|
68
|
+
math,
|
|
69
|
+
media,
|
|
70
|
+
mermaid,
|
|
71
|
+
metrics,
|
|
72
|
+
outline,
|
|
73
|
+
properties,
|
|
74
|
+
qr,
|
|
75
|
+
sources,
|
|
76
|
+
steps,
|
|
77
|
+
table,
|
|
78
|
+
tabs,
|
|
79
|
+
tests,
|
|
80
|
+
typeset,
|
|
81
|
+
zoom,
|
|
82
|
+
},
|
|
83
|
+
options,
|
|
84
|
+
);
|