@mirrordown/core 0.1.0 → 0.1.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/CHANGELOG.md +17 -0
- package/dist/index.d.mts +68 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +621 -169
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
## 0.1.1
|
|
5
|
+
<sub>2026-10-28</sub>
|
|
6
|
+
|
|
7
|
+
- *(patch)*
|
|
8
|
+
Add the mermaid-pele plugin set: ` ```mermaid ` code blocks render to inline SVG at build time with [Pele](https://pele.run), so diagrams need no JavaScript on the page and no headless browser in the build, and they render in VSCode's preview. The API follows rehype-mermaid's (`prefix`, `errorFallback`, Mermaid `config` as `config`), with Pele's render options passed through; a diagram that fails to render fails the build at its line unless `errorFallback` handles it. Each diagram's ids are prefixed with a hash of its source (and a count for repeats), attributes on the fence (`{#id .class}`) go on the `<svg>`, and the stylesheet themes Pele's CSS variables from the page's `color-scheme`. The markdown-it, rehype and Sätteri plugins emit identical HTML.
|
|
9
|
+
- *(patch)*
|
|
10
|
+
Add the caption plugin set: a `~:` line written right after a block captions it, wrapping the block in `<figure class="markdown-caption">` with a `<figcaption>`. Any block can take a caption (an image, paragraph, quote, code, table, list, or the containers other plugins add); a heading, thematic break, raw HTML or another caption can't. An image alone in its paragraph becomes the figure's content, and its alt text stays its alt text. The caption runs to the end of its paragraph and holds inline markdown; the `>` markers and indentation a caption line is written with decide which block it captions, as attrs places a line of attributes, and attributes ending a caption go on the figure. The markdown-it, remark and Sätteri plugins emit identical HTML.
|
|
11
|
+
- *(patch)*
|
|
12
|
+
Tab and step headers are placed by their `>` markers in remark and Sätteri, as markdown-it reads them. A header right after a paragraph, at its level, interrupts it and starts a group. A header written with a panel's or step body's own `>` is that panel's content: `% Tab` or `@1. Step` there starts a group inside it, and a nested header (`%%`, `@@`) with nothing to nest in stays text. Before, both became the next tab or step of the outer group.
|
|
13
|
+
- *(patch)*
|
|
14
|
+
A line written without a tab panel's or step body's `>` right after the last panel now starts a paragraph after the group in remark and Sätteri, as markdown-it reads it, instead of continuing the panel's last paragraph (CommonMark's lazy continuation). The lines after it, and attributes ending them, go with it.
|
|
15
|
+
- *(patch)*
|
|
16
|
+
An alert (`> [!NOTE]`) after a step, with a blank line between, is now a block of its own after the steps in every engine, whether or not the alerts plugin reads it. A plain quote there still continues the last step's body. markdown-it took the alert into the body as text, and remark into the body without its title.
|
|
17
|
+
- *(patch)*
|
|
18
|
+
Captioned lightbox images: a lightbox image (`!`) followed by a `~:` caption is now the figure's content, so its trigger sits directly in the `<figure>` without unwrap-images. The lightbox plugins take a `caption` option (off by default) that shows a captioned image's caption under it in the dialog; repeated images share one dialog, which shows the first caption any of them has. The presets pass lightbox options through (`lightbox: { caption: true }`). The lightbox READMEs are now generated from its guide.
|
|
19
|
+
|
|
3
20
|
## 0.1.0
|
|
4
21
|
<sub>2026-10-28</sub>
|
|
5
22
|
|
package/dist/index.d.mts
CHANGED
|
@@ -56,6 +56,8 @@ interface AlertOptions {
|
|
|
56
56
|
}
|
|
57
57
|
/** Inline SVG icon markup for each {@link AlertType}. */
|
|
58
58
|
export declare const ICONS: Record<AlertType, string>;
|
|
59
|
+
/** Whether a source line opens an alert (`> [!NOTE]`), after its `>` markers and indentation, whether or not the alerts plugin reads it: a block that takes the quote after it as more of its content (a step body) leaves an alert be. */
|
|
60
|
+
export declare const isAlertMarkerLine: (line: string) => boolean;
|
|
59
61
|
/** How an alert keyword resolves under a plugin's options. */
|
|
60
62
|
interface AlertResolver {
|
|
61
63
|
/** The canonical type for a `[!KEYWORD]`, or `undefined` if it is not an alert. */
|
|
@@ -190,8 +192,10 @@ export declare const LIGHTBOX_MARKER: RegExp;
|
|
|
190
192
|
export declare const lightboxId: (src: string) => string;
|
|
191
193
|
/** The button that replaces an opted-in image and opens its dialog. */
|
|
192
194
|
export declare const lightboxTrigger: <C>(id: string, image: C) => HastElementLike<C>;
|
|
193
|
-
/** The modal dialog, appended at the document end, showing the image full size. */
|
|
194
|
-
export declare const lightboxDialog: <C>(id: string, image: C) => HastElementLike<HastElementLike<C>>;
|
|
195
|
+
/** The modal dialog, appended at the document end, showing the image full size, and its caption under it when one is given. */
|
|
196
|
+
export declare const lightboxDialog: <C>(id: string, image: C, caption?: C[]) => HastElementLike<HastElementLike<C>>;
|
|
197
|
+
/** Whether a node is a caption's figure (`<figure class="markdown-caption">`, as the caption plugins make): an image that is its content shows the figure's caption in its lightbox dialog, with the `caption` option. */
|
|
198
|
+
export declare const isCaptionFigure: (node: HastLike | undefined) => boolean;
|
|
195
199
|
/**
|
|
196
200
|
* The `[term, title]` pairs a paragraph's text defines, when every line of it is a `*[term]: title` definition; otherwise `undefined` (the paragraph is ordinary text).
|
|
197
201
|
*/
|
|
@@ -212,6 +216,8 @@ interface StepsListNode {
|
|
|
212
216
|
type: "stepsList";
|
|
213
217
|
depth: number;
|
|
214
218
|
containerClass?: string;
|
|
219
|
+
/** A group written in a step's body (`@1.` with the body's `>`), which renders in the body, rather than the step's `@@` sub-steps. */
|
|
220
|
+
inBody?: boolean;
|
|
215
221
|
children: StepsItemNode[];
|
|
216
222
|
data?: {
|
|
217
223
|
attrsRole?: string;
|
|
@@ -235,7 +241,7 @@ interface StepsItemNode {
|
|
|
235
241
|
hProperties?: Properties;
|
|
236
242
|
};
|
|
237
243
|
}
|
|
238
|
-
export declare const processStepsInChildren: (children: Array<BlockContent | DefinitionContent | Root["children"][number]>, containerClass: string, sourceLines?: readonly string[]) => void;
|
|
244
|
+
export declare const processStepsInChildren: (children: Array<BlockContent | DefinitionContent | Root["children"][number]>, containerClass: string, sourceLines?: readonly string[], quotes?: number, parentType?: string) => void;
|
|
239
245
|
/**
|
|
240
246
|
* Turn every step sequence in `root` into `stepsList` nodes, at the top level and inside any container (blockquotes, list items, tab panels…), walking into the lists it builds so nested sequences are found too. With the document's `source`, a step header that CommonMark lazily continued into a nested paragraph is recognized too, as markdown-it reads it.
|
|
241
247
|
*/
|
|
@@ -279,7 +285,7 @@ export declare const stripAttrs: (text: string) => string;
|
|
|
279
285
|
export declare const tabsBlockId: (index: number, groupId: string) => string;
|
|
280
286
|
/** The plain text of a tab label (text and inline code; other markup contributes its text, images nothing), for its group id and `aria-label`. */
|
|
281
287
|
export declare const tabLabelText: (nodes: PhrasingContent[]) => string;
|
|
282
|
-
export declare const processTabsInChildren: (children: Array<BlockContent | DefinitionContent | RootContent>, containerClass: string, checkBlankLines?: boolean, sourceLines?: readonly string[]) => void;
|
|
288
|
+
export declare const processTabsInChildren: (children: Array<BlockContent | DefinitionContent | RootContent>, containerClass: string, checkBlankLines?: boolean, sourceLines?: readonly string[], quotes?: number, parentType?: string) => void;
|
|
283
289
|
/**
|
|
284
290
|
* Recognize every tab group in the tree: at the root, then inside every container (step bodies, list items, other tabs' panels). Blank-line checks only apply at the root: blank lines inside a blockquote leave position gaps that would wrongly end a group once its content has been lifted out of the blockquote. With the document's `source`, a tab header that CommonMark lazily continued into a nested panel is placed by its `>` markers, as markdown-it reads it.
|
|
285
291
|
*/
|
|
@@ -325,5 +331,62 @@ export declare const svgSpriteId: (relativePath: string) => string;
|
|
|
325
331
|
* The markup for every occurrence of one SVG file, given each occurrence's alt text in document order: the SVG itself, or, with deduplication and more than one occurrence, a hidden sprite on the first and a `<use>` of it on each. `null` when the limits leave the images as they are. `relativePath` is the file's path relative to the document, with `/` separators, for the sprite id.
|
|
326
332
|
*/
|
|
327
333
|
export declare const inlineSvgMarkup: (content: string, alts: readonly string[], relativePath: string, limits: InlineSvgLimits) => string[] | null;
|
|
328
|
-
|
|
334
|
+
/** An HTML attribute, as markdown-it's tokens hold them. */
|
|
335
|
+
type MermaidAttribute = [name: string, value: string];
|
|
336
|
+
/** A diagram's source as Pele reads it: line endings normalized, as markdown-it already has them. */
|
|
337
|
+
export declare const mermaidSource: (text: string) => string;
|
|
338
|
+
/**
|
|
339
|
+
* A document's id prefixes, one per diagram in document order: `prefix`, then a hash of the diagram's source, so a diagram's ids don't change when others are edited, with `-2`, `-3`… for repeats of one diagram. Pele namespaces every id it writes (an accessible title, a gradient) under it. Create one per document.
|
|
340
|
+
*/
|
|
341
|
+
export declare const mermaidIdPrefixes: (prefix: string) => ((source: string) => string);
|
|
342
|
+
/**
|
|
343
|
+
* Pele's `<svg>` with the attributes the diagram's element had (from an attribute block such as `{#id .class}`): classes are added after Pele's, a style after Pele's (whose theme variables the diagram needs), and anything else is set, replacing Pele's value. The class that marked the element as a diagram is dropped.
|
|
344
|
+
*/
|
|
345
|
+
export declare const mermaidSvg: (svg: string, attributes: readonly MermaidAttribute[]) => string;
|
|
346
|
+
/** A hast element's properties as attributes; `className` becomes `class`, and other names are kept as the attribute plugins write them. */
|
|
347
|
+
export declare const hastAttributes: (properties: Record<string, unknown> | undefined) => MermaidAttribute[];
|
|
348
|
+
/**
|
|
349
|
+
* The diagram a `<pre>` holds, as rehype-mermaid finds them: a `<pre>` whose only content (besides whitespace) is a `<code class="language-mermaid">`, which is how a fenced `mermaid` block renders, or a `<pre class="mermaid">`. `element` is the one whose attributes the `<svg>` takes. `undefined` for anything else.
|
|
350
|
+
*/
|
|
351
|
+
export declare const mermaidDiagram: (pre: HastLike) => {
|
|
352
|
+
source: string;
|
|
353
|
+
element: HastLike;
|
|
354
|
+
} | undefined;
|
|
355
|
+
/**
|
|
356
|
+
* The error a diagram that failed to render throws: Pele's message, at the document line Pele located the problem on (counting from `line`, the line the diagram's element starts on), or at `line` itself when Pele has no location. The original error is the `cause`.
|
|
357
|
+
*/
|
|
358
|
+
export declare const mermaidFailure: (error: unknown, line: number | undefined) => Error;
|
|
359
|
+
/**
|
|
360
|
+
* A block a line can be written in, outermost first: a blockquote (or another block written with `>` markers, such as a tab panel), by how many `>` markers lead up to its own, or a list item (or a definition), by the column its content starts at.
|
|
361
|
+
*/
|
|
362
|
+
type LineContainer = {
|
|
363
|
+
kind: `quote`;
|
|
364
|
+
markers: number;
|
|
365
|
+
} | {
|
|
366
|
+
kind: `item`;
|
|
367
|
+
column: number;
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* How many of `containers`, outermost first, a line is written in. Tabs count as one column.
|
|
371
|
+
*/
|
|
372
|
+
export declare const containersKept: (line: string, containers: readonly LineContainer[]) => number;
|
|
373
|
+
/**
|
|
374
|
+
* The columns the content of the list items opened on a line starts at, in the order they open, as CommonMark reads a list marker: up to four spaces after it belong to the marker, more start indented content one column after.
|
|
375
|
+
*/
|
|
376
|
+
export declare const itemColumns: (line: string) => number[];
|
|
377
|
+
/** The class of the `<figure>` a caption wraps its block in. */
|
|
378
|
+
export declare const CAPTION_CLASS = "markdown-caption";
|
|
379
|
+
/** Whether a source line is a caption line: `~:`, whitespace and the caption's first word after its `>` markers and indentation. An escaped `\~:` isn't one, nor is a marker with nothing after it. */
|
|
380
|
+
export declare const isCaptionLine: (line: string) => boolean;
|
|
381
|
+
/** Whether text starts with a caption marker, as a parser gives a caption line's text (inline markdown may follow in other nodes). */
|
|
382
|
+
export declare const startsCaption: (text: string) => boolean;
|
|
383
|
+
/** The text after a caption marker. */
|
|
384
|
+
export declare const stripCaptionMarker: (text: string) => string;
|
|
385
|
+
/** The properties of a caption's `<figure>`: its class, then the attributes written at the end of the caption (a class joins it). */
|
|
386
|
+
export declare const figureProperties: (author?: Properties) => Properties;
|
|
387
|
+
/**
|
|
388
|
+
* Wrap each captioned block of an mdast tree, with its caption, in a `figure` node (`hName: "figure"`, class `markdown-caption`) whose last child is a `figcaption` node. `source` is the document the tree was parsed from: caption lines are found, and placed, by their source lines.
|
|
389
|
+
*/
|
|
390
|
+
export declare const processCaptions: (root: Root, source: string) => void;
|
|
391
|
+
export type { AbbreviationPart, AlertOptions, AlertParagraph, AlertResolver, AlertType, DelimiterMarker, EditableTree, HastElementLike, HastLike, InlineSvgLimits, LineContainer, MermaidAttribute, PhrasingLike, Positioned, ReadAttributes, ScriptSyntax, SpanNodes, SpanTransform, StepsItemNode, StepsListNode, StepsTitleNode, TabsItemNode, TabsLabelNode, TabsListNode, TextLikeNode, TreeNode };
|
|
329
392
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/escapes.ts","../src/github-alerts/types.ts","../src/github-alerts/icons.ts","../src/github-alerts/index.ts","../src/spans.ts","../src/delimited.ts","../src/kbd.ts","../src/scripts.ts","../src/hast.ts","../src/abbr.ts","../src/steps.ts","../src/tabs.ts","../src/editable.ts","../src/cut-attributes.ts","../src/inline-svg.ts"],"mappings":";;;;;;;;qBAqBa,iBACX,eACA,gBACA,eACA,gBACC;;qBAyBU,cAAe,eAAe,SAAS;;qBAYvC,gBAAiB;;UAMb;EACf;EACA;EACA;IAEM;MAAS;;IACT;MAAO;;;EAGb,WAAW;;;;;;;qBAQA,kBACX,MAAM,cACN;;KCvFU;;qBAoBC,eAAe,eAAe;;qBAiC9B,eAAe,OAAO;;UAmBlB;;;;;;EAMf,QAAQ;;EAER,SAAS,QAAQ,OAAO;;EAExB;;EAEA;;EAEA;;;qBC9EW,OAAO,OAAO;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/escapes.ts","../src/github-alerts/types.ts","../src/github-alerts/icons.ts","../src/github-alerts/index.ts","../src/spans.ts","../src/delimited.ts","../src/kbd.ts","../src/scripts.ts","../src/hast.ts","../src/abbr.ts","../src/steps.ts","../src/tabs.ts","../src/editable.ts","../src/cut-attributes.ts","../src/inline-svg.ts","../src/mermaid-pele.ts","../src/line-containers.ts","../src/caption.ts"],"mappings":";;;;;;;;qBAqBa,iBACX,eACA,gBACA,eACA,gBACC;;qBAyBU,cAAe,eAAe,SAAS;;qBAYvC,gBAAiB;;UAMb;EACf;EACA;EACA;IAEM;MAAS;;IACT;MAAO;;;EAGb,WA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