@mirrordown/remd-tabs 0.1.3 → 0.2.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 +39 -0
- package/README.md +11 -37
- package/dist/index.d.mts +11 -55
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -378
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 0.2.1
|
|
9
|
+
<sub>2026-10-28</sub>
|
|
10
|
+
|
|
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
|
+
|
|
16
|
+
## 0.2.0
|
|
17
|
+
<sub>2026-10-28</sub>
|
|
18
|
+
|
|
19
|
+
- *(minor)*
|
|
20
|
+
Make `mdit-tabs` and `remd-tabs` render identical HTML. `remd-tabs` no longer drops a depth-skipping header line (`% Tab One` followed by `%%% Too Deep`) and pulls the following content into the previous tab: the skipped-depth line now ends the group and renders as an ordinary paragraph, and a depth-1 header after it starts a new group, as in `mdit-tabs`. `remd-tabs` also splits a tab header that a nested blockquote lazily absorbed (`> > quote` followed by `% Tab Two`), which previously merged the next tab into the quote. `mdit-tabs` now emits the radio inputs' `hidden` and `checked` attributes bare, as `remd-tabs` does, instead of `hidden=""` and `checked=""`.
|
|
21
|
+
- *(minor)*
|
|
22
|
+
Tab labels behave the same in every engine:
|
|
23
|
+
|
|
24
|
+
- `remd-tabs` keeps a tab's label in the tree, as a `tabsLabel` node that is the first child of each `tabsItem` (the `label` field is gone), so remark plugins that run after it also apply to the label, and a panel's `aria-label` is the label's final text.
|
|
25
|
+
- `data-tabs-group` hashes each label's plain text without a trailing attrs block, as the tabs specification describes. `mdit-tabs` hashed the raw markdown, so labels with links, images, entities or escapes got different ids in markdown-it and remark; labels with a trailing `{…}` change id in both.
|
|
26
|
+
- `mdit-tabs` escapes a panel's `aria-label` once: `npm & yarn` rendered as `aria-label="npm &amp; yarn"`.
|
|
27
|
+
- `mdit-tabs` nests its panel tokens inside the tabs tokens, so `mdit-sectionize` no longer opens a `<section>` around a heading in a tab panel that closed outside the panel.
|
|
28
|
+
- *(minor)*
|
|
29
|
+
Tab groups nested in step bodies and other containers work in every engine:
|
|
30
|
+
|
|
31
|
+
- Block ids (the radio `name` and input ids) number the document's tab groups in the order they open, combined with the group id, instead of hashing a start line that nested groups don't reliably have. Two groups with the same labels in different steps shared radio names, so the first loaded with no panel open and the second's tabs switched the first. Ids of the first group on a page are unchanged; later groups' ids change. Core exports `tabsBlockId`, and `TabsListNode` no longer carries a `blockId`.
|
|
32
|
+
- `mdit-tabs` keeps a group together across blank lines inside a container (a step body, tab panel, blockquote or list item) when another entry follows, as `remd-tabs` does: the empty `>` lines between entries are the container's own. At the top level a blank line still ends a group.
|
|
33
|
+
- *(patch)*
|
|
34
|
+
A tab header written right after nested tab content (`> > Option C body.` then `% Code`) starts a tab in the outer group in every engine. CommonMark lazily continues the nested paragraph with it, so the remark and Sätteri plugins put it in the inner group (the tabs guide's own "Default open tab" demo showed `Code` beside `Option C`); they now read the source's `>` markers as markdown-it does, keeping the header at the depth it was written with and the blockquote structure of the lines after it. `processTabs` takes the document's source for this; the marker handling is shared with steps.
|
|
35
|
+
- *(patch)*
|
|
36
|
+
A tab header that skips a level no longer loses content in the remark and Sätteri plugins, which dropped it and its body; they now render it as `mdit-tabs` does. In a tab's explicit `> %` body it stays in that panel as text, after any group nested there; in a group of plain `>` bodies it ends the group, and it and the lines after it follow the group as ordinary content, with the blockquotes their `>` markers give. A panel's content now also renders in document order in both plugins, rather than its body before its nested groups.
|
|
37
|
+
- *(patch)*
|
|
38
|
+
Paragraphs in tab panels and step bodies keep what they had when recognition splits them around a header:
|
|
39
|
+
|
|
40
|
+
- A hard break (`line\` then `more`) stays a `<br>` in `remd-tabs`, `remd-steps`, `sat-tabs` and `sat-steps`; it became a plain line break, unlike in `mdit-tabs` and `mdit-steps`.
|
|
41
|
+
- Text split around a header keeps its source position, and the lines left together are one text node again, as remark gives them.
|
|
42
|
+
- In `sat-tabs` and `sat-steps`, a paragraph keeps the attributes Sätteri read from its end. A header right after a panel's last paragraph continues that paragraph in CommonMark, so Sätteri saw the paragraph's attribute block mid-paragraph; with Sätteri's `attributes` feature on, the plugins now place that block once the header is split off, where Sätteri would have.
|
|
43
|
+
- `mdit-tabs` and `mdit-steps` give the panel's opening token its body as `meta.attrsSource`, since the tokens inside index the body's lines, so `mdit-attrs` can read a line's indentation there.
|
|
44
|
+
|
|
6
45
|
## 0.1.3
|
|
7
46
|
<sub>2026-06-28</sub>
|
|
8
47
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mirrordown/remd-tabs
|
|
2
2
|
|
|
3
|
-
> Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified
|
|
3
|
+
> Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified, markdown-it and Sätteri ecosystems.
|
|
4
4
|
|
|
5
5
|
A remark/rehype (unified) plugin for the `tabs` syntax extension.
|
|
6
6
|
|
|
@@ -21,20 +21,15 @@ Write a `% Label` line followed by a `>` blockquote for each tab's content:
|
|
|
21
21
|
|
|
22
22
|
````markdown
|
|
23
23
|
% JavaScript
|
|
24
|
-
|
|
25
24
|
> ```js
|
|
26
25
|
> console.log("Hello, world!");
|
|
27
26
|
> ```
|
|
28
|
-
|
|
29
|
-
> % TypeScript
|
|
30
|
-
>
|
|
27
|
+
% TypeScript
|
|
31
28
|
> ```ts
|
|
32
29
|
> const greeting: string = "Hello, world!";
|
|
33
30
|
> console.log(greeting);
|
|
34
31
|
> ```
|
|
35
|
-
|
|
36
|
-
> % Python
|
|
37
|
-
>
|
|
32
|
+
% Python
|
|
38
33
|
> ```py
|
|
39
34
|
> print("Hello, world!")
|
|
40
35
|
> ```
|
|
@@ -44,15 +39,14 @@ Write a `% Label` line followed by a `>` blockquote for each tab's content:
|
|
|
44
39
|
|
|
45
40
|
Mark a tab with `%+` to make it open by default (the first tab is open by default otherwise):
|
|
46
41
|
|
|
47
|
-
|
|
42
|
+
````markdown
|
|
48
43
|
% Option A
|
|
49
|
-
|
|
50
44
|
> This tab is not selected by default.
|
|
51
|
-
|
|
45
|
+
%+ Option B
|
|
52
46
|
> This tab opens by default.
|
|
53
|
-
|
|
47
|
+
% Option C
|
|
54
48
|
> This tab is not selected by default.
|
|
55
|
-
|
|
49
|
+
````
|
|
56
50
|
|
|
57
51
|
### Nested tabs
|
|
58
52
|
|
|
@@ -61,20 +55,16 @@ Use `%%` for a second level of nesting inside a tab:
|
|
|
61
55
|
````markdown
|
|
62
56
|
% Frontend
|
|
63
57
|
%% React
|
|
64
|
-
|
|
65
58
|
> ```tsx
|
|
66
59
|
> export function App() {
|
|
67
60
|
> return <h1>Hello</h1>;
|
|
68
61
|
> }
|
|
69
62
|
> ```
|
|
70
|
-
|
|
71
|
-
> %% Vue
|
|
72
|
-
>
|
|
63
|
+
%% Vue
|
|
73
64
|
> ```vue
|
|
74
65
|
> <template><h1>Hello</h1></template>
|
|
75
66
|
> ```
|
|
76
|
-
|
|
77
|
-
> % Backend
|
|
67
|
+
% Backend
|
|
78
68
|
> Node.js or any server runtime.
|
|
79
69
|
````
|
|
80
70
|
|
|
@@ -114,24 +104,8 @@ import "@mirrordown/remd-tabs/tabs.css";
|
|
|
114
104
|
export default defineConfig({
|
|
115
105
|
markdown: {
|
|
116
106
|
remarkPlugins: [remarkTabs],
|
|
117
|
-
remarkRehype: { handlers: tabsHastHandlers }
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### VitePress
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
// .vitepress/config.ts
|
|
126
|
-
import { defineConfig } from "vitepress";
|
|
127
|
-
import { remarkTabs, tabsHastHandlers } from "@mirrordown/remd-tabs";
|
|
128
|
-
import "@mirrordown/remd-tabs/tabs.css";
|
|
129
|
-
|
|
130
|
-
export default defineConfig({
|
|
131
|
-
markdown: {
|
|
132
|
-
remarkPlugins: [remarkTabs],
|
|
133
|
-
remarkRehype: { handlers: tabsHastHandlers }
|
|
134
|
-
}
|
|
107
|
+
remarkRehype: { handlers: tabsHastHandlers },
|
|
108
|
+
},
|
|
135
109
|
});
|
|
136
110
|
```
|
|
137
111
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,53 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Data, Element, ElementContent, Literal, Nodes as Nodes$1, Properties, RootContent, Text } from "hast";
|
|
1
|
+
import { TabsItemNode, TabsLabelNode, TabsListNode } from "@mirrordown/core";
|
|
3
2
|
import { Plugin } from "unified";
|
|
3
|
+
import { Definition, FootnoteDefinition, Nodes, Parents, Root } from "mdast";
|
|
4
|
+
import { Data, Element, ElementContent, Literal, Nodes as Nodes$1, Properties, RootContent, Text } from "hast";
|
|
4
5
|
import { Node, Point, Position } from "unist";
|
|
5
|
-
|
|
6
|
-
//#region src/types.d.ts
|
|
7
6
|
/** Options for the {@link remarkTabs} plugin. */
|
|
8
7
|
interface TabsOptions {
|
|
9
8
|
/** Class applied to the tabs container element (default `markdown-tabs`). */
|
|
10
9
|
containerClass?: string;
|
|
11
10
|
}
|
|
12
|
-
interface TabsListNode {
|
|
13
|
-
type: "tabsList";
|
|
14
|
-
depth: number;
|
|
15
|
-
containerClass?: string;
|
|
16
|
-
groupId: string;
|
|
17
|
-
blockId: string;
|
|
18
|
-
children: TabsItemNode[];
|
|
19
|
-
data?: {
|
|
20
|
-
attrsRole?: string;
|
|
21
|
-
hProperties?: Properties;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
interface TabsItemNode {
|
|
25
|
-
type: "tabsItem";
|
|
26
|
-
depth: number;
|
|
27
|
-
label: PhrasingContent[];
|
|
28
|
-
labelText: string;
|
|
29
|
-
open: boolean;
|
|
30
|
-
children: Array<BlockContent | DefinitionContent | TabsListNode>;
|
|
31
|
-
data?: {
|
|
32
|
-
attrsRole?: string;
|
|
33
|
-
attrsTitle?: PhrasingContent[];
|
|
34
|
-
attrsItemTitle?: boolean;
|
|
35
|
-
hProperties?: Properties;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/augment.d.ts
|
|
40
11
|
declare module "mdast" {
|
|
41
12
|
interface RootContentMap {
|
|
42
13
|
tabsList: TabsListNode;
|
|
43
14
|
tabsItem: TabsItemNode;
|
|
15
|
+
tabsLabel: TabsLabelNode;
|
|
44
16
|
}
|
|
45
17
|
interface BlockContentMap {
|
|
46
18
|
tabsList: TabsListNode;
|
|
47
19
|
}
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region ../../node_modules/vfile-message/lib/index.d.ts
|
|
20
|
+
}
|
|
51
21
|
/**
|
|
52
22
|
* Message.
|
|
53
23
|
*/
|
|
@@ -553,11 +523,7 @@ type Options$3 = {
|
|
|
553
523
|
*/
|
|
554
524
|
source?: string | null | undefined;
|
|
555
525
|
};
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region ../../node_modules/vfile-message/index.d.ts
|
|
558
526
|
type Options$2 = Options$3;
|
|
559
|
-
//#endregion
|
|
560
|
-
//#region ../../node_modules/vfile/lib/index.d.ts
|
|
561
527
|
declare class VFile {
|
|
562
528
|
/**
|
|
563
529
|
* Create a new virtual file.
|
|
@@ -2013,10 +1979,8 @@ type NodeLike = object & {
|
|
|
2013
1979
|
type: string;
|
|
2014
1980
|
position?: Position | undefined;
|
|
2015
1981
|
};
|
|
2016
|
-
//#endregion
|
|
2017
|
-
//#region ../../node_modules/vfile/index.d.ts
|
|
2018
1982
|
// See: <https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts>
|
|
2019
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
1983
|
+
declare const emptyObjectSymbol: unique symbol;
|
|
2020
1984
|
/**
|
|
2021
1985
|
* Things that can be passed to the constructor.
|
|
2022
1986
|
*/
|
|
@@ -2130,8 +2094,6 @@ interface Options$1 {
|
|
|
2130
2094
|
* Can either be text or a `Uint8Array` structure.
|
|
2131
2095
|
*/
|
|
2132
2096
|
type Value = Uint8Array | string;
|
|
2133
|
-
//#endregion
|
|
2134
|
-
//#region ../../node_modules/mdast-util-to-hast/lib/state.d.ts
|
|
2135
2097
|
/**
|
|
2136
2098
|
* Handle a node.
|
|
2137
2099
|
*/
|
|
@@ -2327,8 +2289,6 @@ type State = {
|
|
|
2327
2289
|
*/
|
|
2328
2290
|
wrap: <Type extends RootContent>(nodes: Array<Type>, loose?: boolean | undefined) => Array<Text | Type>;
|
|
2329
2291
|
};
|
|
2330
|
-
//#endregion
|
|
2331
|
-
//#region ../../node_modules/mdast-util-to-hast/lib/footer.d.ts
|
|
2332
2292
|
/**
|
|
2333
2293
|
* Generate content for the backreference dynamically.
|
|
2334
2294
|
*
|
|
@@ -2373,8 +2333,6 @@ type FootnoteBackContentTemplate = (referenceIndex: number, rereferenceIndex: nu
|
|
|
2373
2333
|
* `charlie`, as it is the second used definition
|
|
2374
2334
|
*/
|
|
2375
2335
|
type FootnoteBackLabelTemplate = (referenceIndex: number, rereferenceIndex: number) => string;
|
|
2376
|
-
//#endregion
|
|
2377
|
-
//#region ../../node_modules/mdast-util-to-hast/index.d.ts
|
|
2378
2336
|
/**
|
|
2379
2337
|
* Raw string of HTML embedded into HTML AST.
|
|
2380
2338
|
*/
|
|
@@ -2414,7 +2372,8 @@ declare module 'hast' {
|
|
|
2414
2372
|
*/
|
|
2415
2373
|
raw: Raw;
|
|
2416
2374
|
}
|
|
2417
|
-
}
|
|
2375
|
+
}
|
|
2376
|
+
// Register data on mdast.
|
|
2418
2377
|
declare module 'mdast' {
|
|
2419
2378
|
interface Data {
|
|
2420
2379
|
/**
|
|
@@ -2443,12 +2402,9 @@ declare module 'mdast' {
|
|
|
2443
2402
|
hProperties?: Properties | undefined;
|
|
2444
2403
|
}
|
|
2445
2404
|
}
|
|
2446
|
-
//#endregion
|
|
2447
|
-
//#region src/plugin.d.ts
|
|
2448
2405
|
/** remark plugin for tabbed content blocks, rendered via {@link tabsHastHandlers}. */
|
|
2449
|
-
declare const remarkTabs: Plugin<[TabsOptions?], Root>;
|
|
2406
|
+
export declare const remarkTabs: Plugin<[TabsOptions?], Root>;
|
|
2450
2407
|
/** mdast-to-hast handler for tabs nodes, for use with `remark-rehype`. */
|
|
2451
|
-
declare const tabsHastHandlers: Record<string, Handler>;
|
|
2452
|
-
|
|
2453
|
-
export { type TabsOptions, remarkTabs, tabsHastHandlers };
|
|
2408
|
+
export declare const tabsHastHandlers: Record<string, Handler>;
|
|
2409
|
+
export type { TabsOptions };
|
|
2454
2410
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["VFileMessage","Options","Node","NodeLike","Point","Position","Error","Array","constructor","reason","options","parent","origin","place","cause","ancestors","column","fatal","file","line","ruleId","source","actual","expected","note","url","type","position","VFileMessage","Options","_$__lib_index_js0","VFile","Compatible","Data","Array","VFileMessage","Value","Map","URL","MessageOptions","Node","NodeLike","Point","Position","Error","constructor","value","cwd","data","history","messages","map","result","stored","basename","path","dirname","extname","stem","fail","reason","options","parent","origin","place","cause","info","message","toString","encoding","type","position","Options","VFile","emptyObjectSymbol","Options","MessageOptions","Compatible","VFileCompatible","DataMap","VFileDataMap","Data","VFileData","VFileOptions","ReporterSettings","VFileReporterSettings","Reporter","VFileReporter","Value","VFileValue","URL","Map","Array","file","mappings","names","sourcesContent","sourceRoot","sources","version","Record","Partial","key","basename","cwd","data","dirname","extname","history","path","stem","value","Settings","files","options","Uint8Array","createState","MdastNodes","Options","State","tree","options","wrap","Type","HastRootContent","Array","HastText","nodes","loose","Handler","MdastParents","HastElementContent","state","node","parent","Handlers","Record","Partial","VFile","FootnoteBackContentTemplate","FootnoteBackLabelTemplate","HastProperties","allowDangerousHtml","clobberPrefix","file","footnoteBackContent","footnoteBackLabel","footnoteLabel","footnoteLabelProperties","footnoteLabelTagName","handlers","passThrough","unknownHandler","HastNodes","HastElement","MdastDefinition","Map","MdastFootnoteDefinition","all","applyData","from","to","definitionById","footnoteById","footnoteCounts","footnoteOrder","one","patch","Nodes","RootContent","Text","Parents","ElementContent","Properties","Element","Definition","FootnoteDefinition","defaultFootnoteBackContent","ElementContent","Array","_","rereferenceIndex","defaultFootnoteBackLabel","referenceIndex","footer","State","Element","state","FootnoteBackContentTemplate","FootnoteBackLabelTemplate","Data","ElementContent","Literal","Properties","FootnoteBackContentTemplate","FootnoteBackLabelTemplate","Handler","Handlers","Options","State","handlers","defaultHandlers","defaultFootnoteBackContent","defaultFootnoteBackLabel","toHast","Raw","RawData","type","data","_0","ElementData","meta","ElementContentMap","raw","RootContentMap","sideEffect","_1","hChildren","hName","hProperties"],"sources":["../src/types.ts","../src/augment.ts","../../../node_modules/vfile-message/lib/index.d.ts","../../../node_modules/vfile-message/index.d.ts","../../../node_modules/vfile/lib/index.d.ts","../../../node_modules/vfile/index.d.ts","../../../node_modules/mdast-util-to-hast/lib/state.d.ts","../../../node_modules/mdast-util-to-hast/lib/footer.d.ts","../../../node_modules/mdast-util-to-hast/index.d.ts","../src/plugin.ts"],"x_google_ignoreList":[2,3,4,5,6,7,8],"mappings":";;;;;;;UAIi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,SAAe,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_0","Options","NodeLike","Options","_$__lib_index_js0.Options","Data","Map","MessageOptions","Options","Map","Data","MdastParents","HastElementContent","MdastNodes","HastProperties","HastNodes","HastElement","MdastDefinition","MdastFootnoteDefinition","HastRootContent","HastText"],"sources":["../src/types.ts","../src/augment.ts","../../../node_modules/vfile-message/lib/index.d.ts","../../../node_modules/vfile-message/index.d.ts","../../../node_modules/vfile/lib/index.d.ts","../../../node_modules/vfile/index.d.ts","../../../node_modules/mdast-util-to-hast/lib/state.d.ts","../../../node_modules/mdast-util-to-hast/lib/footer.d.ts","../../../node_modules/mdast-util-to-hast/index.d.ts","../src/plugin.ts"],"ignoreList":[2,3,4,5,6,7,8],"mappings":";;;;;;UAOiB;;EAEf;;;YCHU;IACR,UAAU;IACV,UAAU;IACV,WAAW;;YAEH;IACR,UAAU;;;;;;cCTD,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuD9B,YAAY,gBAAgB,UAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDtC,YAAY,gBAAgB,QAAQ,OAAOC,+BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDxE,YAAY,gBAAgB,OAAO,QAAQ,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDxE,YAAY,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuD5B,YAAY,OAAO,QAAQ,cAAc,QAAQ,OAAOA,+BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDrF,YAAY,OAAO,QAAQ,cAAc,OAAO,QAAQ,6BAA6B;;;;;;;;;;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,371 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const TAB_HEADER_RE = /^(%{1,6})(\+)? (.*)/;
|
|
4
|
-
const parseTabHeader = (line) => {
|
|
5
|
-
const m = TAB_HEADER_RE.exec(line);
|
|
6
|
-
if (!m) return null;
|
|
7
|
-
return {
|
|
8
|
-
depth: m[1].length,
|
|
9
|
-
open: m[2] === "+",
|
|
10
|
-
label: m[3]
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const djb2 = (str) => {
|
|
14
|
-
let h = 5381;
|
|
15
|
-
for (let i = 0; i < str.length; i++) h = (h << 5) + h + str.charCodeAt(i) >>> 0;
|
|
16
|
-
return h;
|
|
17
|
-
};
|
|
18
|
-
const stripAttrs = (text) => text.replace(/\s*\{[^}]*\}\s*$/, "").trimEnd();
|
|
19
|
-
const slugify = (text) => text.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
20
|
-
const groupId = (labels) => {
|
|
21
|
-
return djb2([...labels].map(slugify).sort().join("-")).toString(16);
|
|
22
|
-
};
|
|
23
|
-
const blockId = (startLine, gId) => {
|
|
24
|
-
return "tabs-" + djb2(`${startLine}:${gId}`).toString(16);
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/plugin.ts
|
|
28
|
-
const paraToLines = (para) => {
|
|
29
|
-
const segs = [];
|
|
30
|
-
for (const child of para.children) if (child.type === "text") {
|
|
31
|
-
const parts = child.value.split("\n");
|
|
32
|
-
for (let p = 0; p < parts.length; p++) {
|
|
33
|
-
if (p > 0) segs.push(null);
|
|
34
|
-
if (parts[p] !== "") segs.push({
|
|
35
|
-
type: "text",
|
|
36
|
-
value: parts[p]
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
} else if (child.type === "break") segs.push(null);
|
|
40
|
-
else segs.push(child);
|
|
41
|
-
const lines = [[]];
|
|
42
|
-
for (const seg of segs) if (seg === null) lines.push([]);
|
|
43
|
-
else lines[lines.length - 1].push(seg);
|
|
44
|
-
return lines;
|
|
45
|
-
};
|
|
46
|
-
const toPlainText = (nodes) => nodes.map((n) => {
|
|
47
|
-
if (n.type === "text" || n.type === "inlineCode") return "value" in n ? n.value : "";
|
|
48
|
-
if ("children" in n) return toPlainText(n.children);
|
|
49
|
-
return "";
|
|
50
|
-
}).join("");
|
|
51
|
-
const extractHeaderPara = (para, requireDepthOne = true, prevDepth = 0) => {
|
|
52
|
-
const lines = paraToLines(para);
|
|
53
|
-
const tabs = [];
|
|
54
|
-
let currentDepth = prevDepth;
|
|
55
|
-
for (const lineSegs of lines) {
|
|
56
|
-
const first = lineSegs[0];
|
|
57
|
-
if (first?.type !== "text") return null;
|
|
58
|
-
const header = parseTabHeader(first.value);
|
|
59
|
-
if (!header) return null;
|
|
60
|
-
const { depth, open } = header;
|
|
61
|
-
if (tabs.length === 0 && requireDepthOne && depth !== 1) return null;
|
|
62
|
-
if (depth > currentDepth + 1) break;
|
|
63
|
-
currentDepth = depth;
|
|
64
|
-
const labelText = header.label;
|
|
65
|
-
const labelNodes = labelText ? [{
|
|
66
|
-
type: "text",
|
|
67
|
-
value: labelText
|
|
68
|
-
}, ...lineSegs.slice(1)] : lineSegs.slice(1);
|
|
69
|
-
tabs.push({
|
|
70
|
-
depth,
|
|
71
|
-
open,
|
|
72
|
-
labelNodes,
|
|
73
|
-
labelText: toPlainText(labelNodes),
|
|
74
|
-
body: []
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return tabs.length > 0 ? tabs : null;
|
|
78
|
-
};
|
|
79
|
-
const isExplicitBQ = (bq) => bq.children.some((child) => {
|
|
80
|
-
if (child.type !== "paragraph") return false;
|
|
81
|
-
const first = child.children[0];
|
|
82
|
-
return first?.type === "text" && parseTabHeader(first.value.split("\n")[0]) !== null;
|
|
83
|
-
});
|
|
84
|
-
const extractTrailingTabHeader = (node) => {
|
|
85
|
-
const path = [];
|
|
86
|
-
let current = node;
|
|
87
|
-
while ("children" in current && current.children.length > 0) {
|
|
88
|
-
const last = current.children[current.children.length - 1];
|
|
89
|
-
if (last.type === "paragraph") {
|
|
90
|
-
path.push(current);
|
|
91
|
-
const lines = paraToLines(last);
|
|
92
|
-
const lastLine = lines[lines.length - 1];
|
|
93
|
-
if (!lastLine) return null;
|
|
94
|
-
const first = lastLine[0];
|
|
95
|
-
if (first?.type !== "text") return null;
|
|
96
|
-
const header = parseTabHeader(first.value);
|
|
97
|
-
if (!header) return null;
|
|
98
|
-
const labelText = header.label;
|
|
99
|
-
const labelNodes = labelText ? [{
|
|
100
|
-
type: "text",
|
|
101
|
-
value: labelText
|
|
102
|
-
}, ...lastLine.slice(1)] : lastLine.slice(1);
|
|
103
|
-
return {
|
|
104
|
-
header: {
|
|
105
|
-
depth: header.depth,
|
|
106
|
-
open: header.open,
|
|
107
|
-
labelNodes,
|
|
108
|
-
labelText: toPlainText(labelNodes),
|
|
109
|
-
body: []
|
|
110
|
-
},
|
|
111
|
-
truncatedPara: buildParagraph(lines.slice(0, -1)),
|
|
112
|
-
path
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (!("children" in last)) break;
|
|
116
|
-
path.push(current);
|
|
117
|
-
current = last;
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
};
|
|
121
|
-
const splitBlockquote = (bq, explicit) => {
|
|
122
|
-
const segments = [];
|
|
123
|
-
let currentSegment = {
|
|
124
|
-
header: null,
|
|
125
|
-
body: [],
|
|
126
|
-
explicit
|
|
127
|
-
};
|
|
128
|
-
for (const child of bq.children) {
|
|
129
|
-
if (child.type !== "paragraph") {
|
|
130
|
-
const extracted = extractTrailingTabHeader(child);
|
|
131
|
-
if (extracted) {
|
|
132
|
-
const cloned = JSON.parse(JSON.stringify(child));
|
|
133
|
-
let target = cloned;
|
|
134
|
-
for (let pi = 1; pi < extracted.path.length; pi++) target = target.children[target.children.length - 1];
|
|
135
|
-
const deepestParent = target;
|
|
136
|
-
if (extracted.truncatedPara) deepestParent.children[deepestParent.children.length - 1] = extracted.truncatedPara;
|
|
137
|
-
else deepestParent.children.splice(deepestParent.children.length - 1, 1);
|
|
138
|
-
currentSegment.body.push(cloned);
|
|
139
|
-
segments.push(currentSegment);
|
|
140
|
-
currentSegment = {
|
|
141
|
-
header: extracted.header,
|
|
142
|
-
body: [],
|
|
143
|
-
explicit
|
|
144
|
-
};
|
|
145
|
-
} else currentSegment.body.push(child);
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
const lines = paraToLines(child);
|
|
149
|
-
let bodyLines = [];
|
|
150
|
-
for (const lineSegs of lines) {
|
|
151
|
-
const first = lineSegs[0];
|
|
152
|
-
if (first?.type === "text") {
|
|
153
|
-
const header = parseTabHeader(first.value);
|
|
154
|
-
if (header) {
|
|
155
|
-
if (bodyLines.length > 0) {
|
|
156
|
-
const bodyPara = buildParagraph(bodyLines);
|
|
157
|
-
if (bodyPara) currentSegment.body.push(bodyPara);
|
|
158
|
-
bodyLines = [];
|
|
159
|
-
}
|
|
160
|
-
segments.push(currentSegment);
|
|
161
|
-
const labelText = header.label;
|
|
162
|
-
const labelNodes = labelText ? [{
|
|
163
|
-
type: "text",
|
|
164
|
-
value: labelText
|
|
165
|
-
}, ...lineSegs.slice(1)] : lineSegs.slice(1);
|
|
166
|
-
currentSegment = {
|
|
167
|
-
header: {
|
|
168
|
-
depth: header.depth,
|
|
169
|
-
open: header.open,
|
|
170
|
-
labelNodes,
|
|
171
|
-
labelText: toPlainText(labelNodes),
|
|
172
|
-
body: []
|
|
173
|
-
},
|
|
174
|
-
body: [],
|
|
175
|
-
explicit
|
|
176
|
-
};
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
bodyLines.push(lineSegs);
|
|
181
|
-
}
|
|
182
|
-
if (bodyLines.length > 0) {
|
|
183
|
-
const bodyPara = buildParagraph(bodyLines);
|
|
184
|
-
if (bodyPara) currentSegment.body.push(bodyPara);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
segments.push(currentSegment);
|
|
188
|
-
return segments;
|
|
189
|
-
};
|
|
190
|
-
const buildParagraph = (lines) => {
|
|
191
|
-
const children = [];
|
|
192
|
-
for (let i = 0; i < lines.length; i++) {
|
|
193
|
-
if (i > 0) children.push({
|
|
194
|
-
type: "text",
|
|
195
|
-
value: "\n"
|
|
196
|
-
});
|
|
197
|
-
children.push(...lines[i]);
|
|
198
|
-
}
|
|
199
|
-
if (children.length === 0) return null;
|
|
200
|
-
return {
|
|
201
|
-
type: "paragraph",
|
|
202
|
-
children
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
const buildTree = (rawTabs, targetDepth, start, end, containerClass, startLine) => {
|
|
206
|
-
const gId = groupId(rawTabs.slice(start, end).filter((t) => t.depth === targetDepth).map((t) => t.labelText));
|
|
207
|
-
const bId = blockId(startLine, gId);
|
|
208
|
-
const explicitOpenIdx = rawTabs.slice(start, end).findIndex((t) => t.depth === targetDepth && t.open);
|
|
209
|
-
const explicitOpenAbsIdx = explicitOpenIdx >= 0 ? start + explicitOpenIdx : -1;
|
|
210
|
-
const items = [];
|
|
211
|
-
let tabCounter = 0;
|
|
212
|
-
let i = start;
|
|
213
|
-
while (i < end) {
|
|
214
|
-
const raw = rawTabs[i];
|
|
215
|
-
if (raw.depth !== targetDepth) {
|
|
216
|
-
i++;
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
let childEnd = i + 1;
|
|
220
|
-
while (childEnd < end && rawTabs[childEnd].depth > targetDepth) childEnd++;
|
|
221
|
-
const isOpen = explicitOpenAbsIdx >= 0 ? i === explicitOpenAbsIdx : tabCounter === 0;
|
|
222
|
-
const bodyChildren = [...raw.body];
|
|
223
|
-
if (rawTabs.slice(i + 1, childEnd).some((t) => t.depth === targetDepth + 1)) {
|
|
224
|
-
const nested = buildTree(rawTabs, targetDepth + 1, i + 1, childEnd, containerClass, startLine);
|
|
225
|
-
nested.containerClass = containerClass;
|
|
226
|
-
bodyChildren.push(nested);
|
|
227
|
-
}
|
|
228
|
-
items.push({
|
|
229
|
-
type: "tabsItem",
|
|
230
|
-
depth: targetDepth,
|
|
231
|
-
label: raw.labelNodes,
|
|
232
|
-
labelText: raw.labelText,
|
|
233
|
-
open: isOpen,
|
|
234
|
-
children: bodyChildren,
|
|
235
|
-
data: {
|
|
236
|
-
attrsRole: "containerItem",
|
|
237
|
-
attrsTitle: raw.labelNodes,
|
|
238
|
-
attrsItemTitle: true,
|
|
239
|
-
hProperties: {}
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
tabCounter++;
|
|
243
|
-
i = childEnd;
|
|
244
|
-
}
|
|
245
|
-
return {
|
|
246
|
-
type: "tabsList",
|
|
247
|
-
depth: targetDepth,
|
|
248
|
-
groupId: gId,
|
|
249
|
-
blockId: bId,
|
|
250
|
-
children: items,
|
|
251
|
-
data: {
|
|
252
|
-
attrsRole: "container",
|
|
253
|
-
hProperties: {}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
const processTabsInChildren = (children, containerClass, checkBlankLines = true) => {
|
|
258
|
-
const newChildren = [];
|
|
259
|
-
let i = 0;
|
|
260
|
-
while (i < children.length) {
|
|
261
|
-
const node = children[i];
|
|
262
|
-
if (node.type === "paragraph") {
|
|
263
|
-
const headerTabs = extractHeaderPara(node);
|
|
264
|
-
if (headerTabs && headerTabs.length > 0) {
|
|
265
|
-
const rawTabs = [...headerTabs];
|
|
266
|
-
const startLine = (node.position?.start.line ?? 1) - 1;
|
|
267
|
-
let j = i + 1;
|
|
268
|
-
let currentTabIdx = rawTabs.length - 1;
|
|
269
|
-
let prevEndLine = node.position?.end.line ?? 0;
|
|
270
|
-
while (j < children.length) {
|
|
271
|
-
const sibling = children[j];
|
|
272
|
-
const siblingStartLine = sibling.position?.start.line ?? prevEndLine + 1;
|
|
273
|
-
if (checkBlankLines && siblingStartLine > prevEndLine + 1) break;
|
|
274
|
-
if (sibling.type === "blockquote") {
|
|
275
|
-
const bq = sibling;
|
|
276
|
-
const explicit = isExplicitBQ(bq);
|
|
277
|
-
const segments = splitBlockquote(bq, explicit);
|
|
278
|
-
const firstSeg = segments[0];
|
|
279
|
-
if (firstSeg?.header === null) rawTabs[currentTabIdx].body.push(...firstSeg.body);
|
|
280
|
-
const depthOffset = explicit ? rawTabs[rawTabs.length - 1].depth : 0;
|
|
281
|
-
for (let s = 1; s < segments.length; s++) {
|
|
282
|
-
const seg = segments[s];
|
|
283
|
-
if (!seg.header) continue;
|
|
284
|
-
const adjustedDepth = depthOffset + seg.header.depth;
|
|
285
|
-
if (adjustedDepth > rawTabs[rawTabs.length - 1].depth + 1) continue;
|
|
286
|
-
seg.header.depth = adjustedDepth;
|
|
287
|
-
if (explicit) {
|
|
288
|
-
const deferredInnerSegs = [];
|
|
289
|
-
const escapedSegs = [];
|
|
290
|
-
for (const b of seg.body) {
|
|
291
|
-
if (b.type !== "blockquote") {
|
|
292
|
-
if (escapedSegs.length > 0) escapedSegs[escapedSegs.length - 1].body.push(b);
|
|
293
|
-
else seg.header.body.push(b);
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
const innerBq = b;
|
|
297
|
-
if (!isExplicitBQ(innerBq)) {
|
|
298
|
-
const innerSegs = splitBlockquote(innerBq, false);
|
|
299
|
-
const innerFirst = innerSegs[0];
|
|
300
|
-
if (innerFirst?.header === null) seg.header.body.push(...innerFirst.body);
|
|
301
|
-
for (let is = 1; is < innerSegs.length; is++) {
|
|
302
|
-
const innerSeg = innerSegs[is];
|
|
303
|
-
if (!innerSeg.header) continue;
|
|
304
|
-
if (innerSeg.body.length === 0) {
|
|
305
|
-
innerSeg.header.depth = depthOffset;
|
|
306
|
-
escapedSegs.push(innerSeg.header);
|
|
307
|
-
deferredInnerSegs.push(innerSeg);
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
const tentativeDepth = depthOffset + innerSeg.header.depth;
|
|
311
|
-
if (tentativeDepth > rawTabs[rawTabs.length - 1].depth + 1) continue;
|
|
312
|
-
innerSeg.header.depth = tentativeDepth;
|
|
313
|
-
innerSeg.header.body.push(...innerSeg.body);
|
|
314
|
-
deferredInnerSegs.push(innerSeg);
|
|
315
|
-
}
|
|
316
|
-
} else seg.header.body.push(...innerBq.children);
|
|
317
|
-
}
|
|
318
|
-
rawTabs.push(seg.header);
|
|
319
|
-
currentTabIdx = rawTabs.length - 1;
|
|
320
|
-
for (const innerSeg of deferredInnerSegs) {
|
|
321
|
-
if (!innerSeg.header) continue;
|
|
322
|
-
rawTabs.push(innerSeg.header);
|
|
323
|
-
currentTabIdx = rawTabs.length - 1;
|
|
324
|
-
}
|
|
325
|
-
} else {
|
|
326
|
-
seg.header.body.push(...seg.body);
|
|
327
|
-
rawTabs.push(seg.header);
|
|
328
|
-
currentTabIdx = rawTabs.length - 1;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
prevEndLine = sibling.position?.end.line ?? prevEndLine;
|
|
332
|
-
j++;
|
|
333
|
-
} else if (sibling.type === "paragraph") {
|
|
334
|
-
const prevDepth = rawTabs[rawTabs.length - 1].depth;
|
|
335
|
-
const contHeaders = extractHeaderPara(sibling, false, prevDepth);
|
|
336
|
-
if (contHeaders && contHeaders.length > 0) {
|
|
337
|
-
rawTabs.push(...contHeaders);
|
|
338
|
-
currentTabIdx = rawTabs.length - 1;
|
|
339
|
-
prevEndLine = sibling.position?.end.line ?? prevEndLine;
|
|
340
|
-
j++;
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
break;
|
|
344
|
-
} else break;
|
|
345
|
-
}
|
|
346
|
-
const list = buildTree(rawTabs, 1, 0, rawTabs.length, containerClass, startLine);
|
|
347
|
-
list.containerClass = containerClass;
|
|
348
|
-
newChildren.push(list);
|
|
349
|
-
i = j;
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
newChildren.push(node);
|
|
354
|
-
i++;
|
|
355
|
-
}
|
|
356
|
-
children.splice(0, children.length, ...newChildren);
|
|
357
|
-
};
|
|
1
|
+
import { processTabs, stripAttrs, tabLabelText, tabsBlockId } from "@mirrordown/core";
|
|
2
|
+
// src/plugin.ts
|
|
358
3
|
/** remark plugin for tabbed content blocks, rendered via {@link tabsHastHandlers}. */
|
|
359
4
|
const remarkTabs = function(options = {}) {
|
|
360
5
|
const { containerClass = "markdown-tabs" } = options;
|
|
361
|
-
return (tree) => {
|
|
362
|
-
|
|
363
|
-
visit(tree, (node) => {
|
|
364
|
-
if ("children" in node && node.type !== "root") {
|
|
365
|
-
const parent = node;
|
|
366
|
-
if (parent.children.length > 0) processTabsInChildren(parent.children, containerClass, false);
|
|
367
|
-
}
|
|
368
|
-
});
|
|
6
|
+
return (tree, file) => {
|
|
7
|
+
processTabs(tree, containerClass, String(file));
|
|
369
8
|
};
|
|
370
9
|
};
|
|
371
10
|
const mergeHProperties = (base, extra) => {
|
|
@@ -378,15 +17,20 @@ const mergeHProperties = (base, extra) => {
|
|
|
378
17
|
if (extraClass) result.class = base.class ? `${String(base.class)} ${String(extraClass)}` : extraClass;
|
|
379
18
|
return result;
|
|
380
19
|
};
|
|
20
|
+
const groupsRendered = /* @__PURE__ */ new WeakMap();
|
|
381
21
|
const buildTabsHast = (list, containerClass, state) => {
|
|
22
|
+
const index = groupsRendered.get(state) ?? 0;
|
|
23
|
+
groupsRendered.set(state, index + 1);
|
|
24
|
+
const blockId = tabsBlockId(index, list.groupId);
|
|
382
25
|
const labelChildren = [];
|
|
383
26
|
const panelChildren = [];
|
|
384
27
|
list.children.forEach((item, idx) => {
|
|
385
|
-
const
|
|
386
|
-
const
|
|
28
|
+
const label = item.children.find((c) => c.type === "tabsLabel")?.children ?? [];
|
|
29
|
+
const labelPlain = stripAttrs(tabLabelText(label));
|
|
30
|
+
const inputId = `${blockId}-${idx}`;
|
|
387
31
|
const inputProps = {
|
|
388
32
|
type: "radio",
|
|
389
|
-
name:
|
|
33
|
+
name: blockId,
|
|
390
34
|
id: inputId,
|
|
391
35
|
hidden: true,
|
|
392
36
|
...item.open ? { checked: true } : {}
|
|
@@ -407,17 +51,26 @@ const buildTabsHast = (list, containerClass, state) => {
|
|
|
407
51
|
properties: labelProps,
|
|
408
52
|
children: state.all({
|
|
409
53
|
type: "paragraph",
|
|
410
|
-
children:
|
|
54
|
+
children: label
|
|
411
55
|
})
|
|
412
56
|
});
|
|
413
|
-
const bodyBlocks = item.children.filter((c) => c.type !== "tabsList");
|
|
414
|
-
const nestedLists = item.children.filter((c) => c.type === "tabsList");
|
|
415
57
|
const sectionChildren = [];
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
58
|
+
let blocks = [];
|
|
59
|
+
const flush = () => {
|
|
60
|
+
if (blocks.length > 0) sectionChildren.push(...state.all({
|
|
61
|
+
type: "root",
|
|
62
|
+
children: blocks
|
|
63
|
+
}));
|
|
64
|
+
blocks = [];
|
|
65
|
+
};
|
|
66
|
+
for (const child of item.children) {
|
|
67
|
+
if (child.type === "tabsLabel") continue;
|
|
68
|
+
if (child.type === "tabsList") {
|
|
69
|
+
flush();
|
|
70
|
+
sectionChildren.push(buildTabsHast(child, child.containerClass ?? containerClass, state));
|
|
71
|
+
} else blocks.push(child);
|
|
72
|
+
}
|
|
73
|
+
flush();
|
|
421
74
|
const sectionProps = mergeHProperties({
|
|
422
75
|
class: `${containerClass}-panel`,
|
|
423
76
|
"aria-label": labelPlain
|
|
@@ -455,9 +108,9 @@ const buildTabsHast = (list, containerClass, state) => {
|
|
|
455
108
|
};
|
|
456
109
|
/** mdast-to-hast handler for tabs nodes, for use with `remark-rehype`. */
|
|
457
110
|
const tabsHastHandlers = { tabsList(state, node) {
|
|
458
|
-
|
|
111
|
+
const containerClass = node.containerClass ?? "markdown-tabs";
|
|
112
|
+
return buildTabsHast(node, containerClass, state);
|
|
459
113
|
} };
|
|
460
|
-
//#endregion
|
|
461
114
|
export { remarkTabs, tabsHastHandlers };
|
|
462
115
|
|
|
463
116
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["para"],"sources":["../src/utils.ts","../src/plugin.ts"],"sourcesContent":["// Matches: %{1,6}+? label text (prefix-plus form: %+ Label)\n// Groups: 1=% string (depth), 2=+ (open marker, optional), 3=label text\nexport const TAB_HEADER_RE = /^(%{1,6})(\\+)? (.*)/;\n\n// Matches: > or ><space> continuation line\nexport const CONTINUATION_RE = /^> ?/;\n\nexport interface ParsedTabHeader {\n depth: number;\n open: boolean;\n label: string;\n}\n\nexport const parseTabHeader = (line: string): ParsedTabHeader | null => {\n const m = TAB_HEADER_RE.exec(line);\n if (!m) return null;\n return { depth: m[1].length, open: m[2] === \"+\", label: m[3] };\n};\n\nexport const stripContinuation = (line: string): string =>\n line.replace(/^> ?/, \"\");\n\n// djb2 hash — returns an unsigned 32-bit integer\nconst djb2 = (str: string): number => {\n let h = 5381;\n for (let i = 0; i < str.length; i++) {\n h = ((h << 5) + h + str.charCodeAt(i)) >>> 0;\n }\n return h;\n};\n\n// Strip a trailing attrs block like {.class #id} from plain label text.\nexport const stripAttrs = (text: string): string =>\n text.replace(/\\s*\\{[^}]*\\}\\s*$/, \"\").trimEnd();\n\nexport const slugify = (text: string): string =>\n text\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\n// content-based: same label set → same id regardless of page position\nexport const groupId = (labels: string[]): string => {\n const key = [...labels].map(slugify).sort().join(\"-\");\n return djb2(key).toString(16);\n};\n\n// position-based: unique per block even when label sets match\nexport const blockId = (startLine: number, gId: string): string => {\n const key = `${startLine}:${gId}`;\n return \"tabs-\" + djb2(key).toString(16);\n};\n","// This plugin performs heavy tree-rewriting across mdast/hast/unist types\n// that don't unify cleanly; type assertions bridging those boundaries are\n// reviewed and intentional, so the rule is disabled file-wide rather than\n// per-cast. Defensive optional chains on array[i] accesses are also kept\n// because TS doesn't model index access as fallible (noUncheckedIndexedAccess\n// is off project-wide).\n/* oxlint-disable typescript/no-unsafe-type-assertion */\n/* oxlint-disable typescript/no-unnecessary-condition */\nimport { visit } from \"unist-util-visit\";\nimport type { Plugin } from \"unified\";\nimport type {\n Root,\n Paragraph,\n Blockquote,\n PhrasingContent,\n BlockContent,\n DefinitionContent,\n RootContent\n} from \"mdast\";\nimport type { Element, ElementContent, Properties } from \"hast\";\nimport type { Parent } from \"unist\";\nimport type { State, Handler } from \"mdast-util-to-hast\";\nimport type { TabsOptions, TabsListNode, TabsItemNode } from \"./types.js\";\nimport { parseTabHeader, stripAttrs, groupId, blockId } from \"./utils.js\";\n\nexport type { TabsOptions };\n\n// ── Raw extraction types ──────────────────────────────────────────────────────\n\ninterface RawTab {\n depth: number;\n open: boolean;\n labelNodes: PhrasingContent[]; // inline nodes for the label\n labelText: string; // plain text for aria-label / data-tab\n body: Array<BlockContent | DefinitionContent>; // blockquote contents\n}\n\n// ── Paragraph line splitting ──────────────────────────────────────────────────\n\n// Split a paragraph's inline children into lines by text \"\\n\" boundaries.\nconst paraToLines = (para: Paragraph): PhrasingContent[][] => {\n type Seg = PhrasingContent | null;\n const segs: Seg[] = [];\n\n for (const child of para.children) {\n if (child.type === \"text\") {\n const parts = child.value.split(\"\\n\");\n for (let p = 0; p < parts.length; p++) {\n if (p > 0) segs.push(null);\n if (parts[p] !== \"\") segs.push({ type: \"text\", value: parts[p] });\n }\n } else if (child.type === \"break\") {\n segs.push(null);\n } else {\n segs.push(child);\n }\n }\n\n const lines: PhrasingContent[][] = [[]];\n for (const seg of segs) {\n if (seg === null) lines.push([]);\n else lines[lines.length - 1].push(seg);\n }\n return lines;\n};\n\n// Extract plain text from PhrasingContent nodes (strips all markup)\nconst toPlainText = (nodes: PhrasingContent[]): string =>\n nodes\n .map((n) => {\n if (n.type === \"text\" || n.type === \"inlineCode\")\n return \"value\" in n ? n.value : \"\";\n if (\"children\" in n) return toPlainText(n.children);\n return \"\";\n })\n .join(\"\");\n\n// ── Tab group extraction ──────────────────────────────────────────────────────\n\n// Parse a paragraph node that consists entirely of % tab headers (no body\n// content). Returns null if the paragraph isn't all headers.\n// requireDepthOne: if true, the first header must be depth 1 (top-level group start).\n// If false, allows any starting depth (for continuation paragraphs).\nconst extractHeaderPara = (\n para: Paragraph,\n requireDepthOne = true,\n prevDepth = 0\n): RawTab[] | null => {\n const lines = paraToLines(para);\n const tabs: RawTab[] = [];\n let currentDepth = prevDepth;\n\n for (const lineSegs of lines) {\n const first = lineSegs[0];\n if (first?.type !== \"text\") return null;\n\n const header = parseTabHeader(first.value);\n if (!header) return null;\n\n const { depth, open } = header;\n if (tabs.length === 0 && requireDepthOne && depth !== 1) return null;\n if (depth > currentDepth + 1) break;\n currentDepth = depth;\n\n const labelText = header.label;\n const labelNodes: PhrasingContent[] = labelText\n ? [{ type: \"text\", value: labelText }, ...lineSegs.slice(1)]\n : lineSegs.slice(1);\n\n tabs.push({\n depth,\n open,\n labelNodes,\n labelText: toPlainText(labelNodes),\n body: []\n });\n }\n\n return tabs.length > 0 ? tabs : null;\n};\n\n// Split a blockquote node into segments separated by % tab header lines.\n// Each segment is { header: RawTab | null, body: blockquote-like children }.\n//\n// Remark absorbs adjacent non-blank lines into a blockquote, so:\n// % Tab One\n// > Content for tab one.\n// % Tab Two\n// > Content for tab two.\n//\n// Produces: paragraph(\"% Tab One\") + blockquote containing:\n// paragraph(\"Content for tab one.\\n% Tab Two\\nContent for tab two.\")\n//\n// We need to split that paragraph on lines matching tab headers, then\n// reconstruct the body content for each segment.\ninterface BQSegment {\n header: RawTab | null; // null means pre-header content (goes to prev tab)\n body: Array<BlockContent | DefinitionContent>;\n // true when this blockquote was written with explicit `> %` nesting (multiple\n // block children) rather than being the standard absorbed-tabs pattern where\n // remark collapses consecutive `% Tab\\n> body` lines into one blockquote.\n // Used to apply a depth offset and to unwrap nested blockquote bodies.\n explicit: boolean;\n}\n\n// A blockquote is \"explicit\" (`> % Label` nesting) when at least one of its\n// direct paragraph children starts with a tab header. The absorbed pattern\n// (remark collapsing consecutive `% Tab\\n> body` lines into one blockquote)\n// never produces standalone header paragraphs — headers are only embedded\n// inside multi-line text nodes.\nconst isExplicitBQ = (bq: Blockquote): boolean =>\n bq.children.some((child) => {\n if (child.type !== \"paragraph\") return false;\n const first = child.children[0];\n return (\n first?.type === \"text\" &&\n parseTabHeader(first.value.split(\"\\n\")[0]) !== null\n );\n });\n\n// Walk to the deepest last child of a node and return its paragraph if it\n// has a trailing tab header line, along with the truncated paragraph and the\n// extracted RawTab header. Returns null if no trailing tab header is found.\n// This handles cases where remark plugins (e.g. remarkDefinitionList) transform\n// absorbed paragraphs into custom nodes — the trailing \"% Code\" line ends up\n// inside a nested paragraph rather than at the blockquote's top level.\nconst extractTrailingTabHeader = (\n node: BlockContent | DefinitionContent\n): {\n header: RawTab;\n truncatedPara: Paragraph | null;\n path: Array<BlockContent | DefinitionContent>;\n} | null => {\n // Walk to the deepest last child that is a paragraph\n const path: Array<BlockContent | DefinitionContent> = [];\n let current: BlockContent | DefinitionContent = node;\n while (\"children\" in current && current.children.length > 0) {\n const last = current.children[current.children.length - 1] as\n | BlockContent\n | DefinitionContent;\n if (last.type === \"paragraph\") {\n path.push(current);\n // Check if this paragraph's last line is a tab header\n const para = last;\n const lines = paraToLines(para);\n const lastLine = lines[lines.length - 1];\n if (!lastLine) return null;\n const first = lastLine[0];\n if (first?.type !== \"text\") return null;\n const header = parseTabHeader(first.value);\n if (!header) return null;\n const labelText = header.label;\n const labelNodes: PhrasingContent[] = labelText\n ? [{ type: \"text\", value: labelText }, ...lastLine.slice(1)]\n : lastLine.slice(1);\n const rawTab: RawTab = {\n depth: header.depth,\n open: header.open,\n labelNodes,\n labelText: toPlainText(labelNodes),\n body: []\n };\n // Build truncated paragraph without the last line\n const truncatedLines = lines.slice(0, -1);\n const truncatedPara = buildParagraph(truncatedLines);\n return { header: rawTab, truncatedPara, path };\n }\n if (!(\"children\" in last)) break;\n path.push(current);\n current = last;\n }\n return null;\n};\n\nconst splitBlockquote = (bq: Blockquote, explicit: boolean): BQSegment[] => {\n const segments: BQSegment[] = [];\n let currentSegment: BQSegment = { header: null, body: [], explicit };\n\n for (const child of bq.children) {\n if (child.type !== \"paragraph\") {\n // For non-paragraph children (e.g. defList from remarkDefinitionList),\n // check if the deepest last-child paragraph has a trailing tab header.\n // Remark may have absorbed a \"% NextTab\" line into that nested paragraph.\n const extracted = extractTrailingTabHeader(\n child as BlockContent | DefinitionContent\n );\n if (extracted) {\n // Clone the child with the trailing header line removed from its nested paragraph\n const cloned = JSON.parse(JSON.stringify(child)) as\n | BlockContent\n | DefinitionContent;\n // Navigate to the deepest last child and replace the paragraph.\n // Tree walking through heterogeneous mdast Parent shapes — no narrow\n // type fits all the intermediate nodes we descend through.\n interface ParentLike {\n children: ParentLike[];\n }\n let target: ParentLike = cloned as unknown as ParentLike;\n for (let pi = 1; pi < extracted.path.length; pi++) {\n target = target.children[target.children.length - 1];\n }\n const deepestParent = target as unknown as Parent;\n if (extracted.truncatedPara) {\n deepestParent.children[deepestParent.children.length - 1] =\n extracted.truncatedPara;\n } else {\n deepestParent.children.splice(deepestParent.children.length - 1, 1);\n }\n currentSegment.body.push(cloned);\n // Start a new segment for the extracted tab header\n segments.push(currentSegment);\n currentSegment = { header: extracted.header, body: [], explicit };\n } else {\n currentSegment.body.push(child as BlockContent);\n }\n continue;\n }\n\n // Check if this paragraph contains tab headers mixed with body text\n const lines = paraToLines(child);\n let bodyLines: PhrasingContent[][] = [];\n\n for (const lineSegs of lines) {\n const first = lineSegs[0];\n if (first?.type === \"text\") {\n const header = parseTabHeader(first.value);\n if (header) {\n // Flush accumulated body lines into current segment\n if (bodyLines.length > 0) {\n const bodyPara = buildParagraph(bodyLines);\n if (bodyPara) currentSegment.body.push(bodyPara);\n bodyLines = [];\n }\n\n // Save current segment, start a new one\n segments.push(currentSegment);\n\n const labelText = header.label;\n const labelNodes: PhrasingContent[] = labelText\n ? [{ type: \"text\", value: labelText }, ...lineSegs.slice(1)]\n : lineSegs.slice(1);\n\n currentSegment = {\n header: {\n depth: header.depth,\n open: header.open,\n labelNodes,\n labelText: toPlainText(labelNodes),\n body: []\n },\n body: [],\n explicit\n };\n continue;\n }\n }\n bodyLines.push(lineSegs);\n }\n\n // Flush remaining body lines\n if (bodyLines.length > 0) {\n const bodyPara = buildParagraph(bodyLines);\n if (bodyPara) currentSegment.body.push(bodyPara);\n }\n }\n\n segments.push(currentSegment);\n return segments;\n};\n\n// Reconstruct a paragraph node from line arrays\nconst buildParagraph = (lines: PhrasingContent[][]): Paragraph | null => {\n const children: PhrasingContent[] = [];\n for (let i = 0; i < lines.length; i++) {\n if (i > 0) children.push({ type: \"text\", value: \"\\n\" });\n children.push(...lines[i]);\n }\n if (children.length === 0) return null;\n return { type: \"paragraph\", children };\n};\n\n// ── Tree builder ──────────────────────────────────────────────────────────────\n\nconst buildTree = (\n rawTabs: RawTab[],\n targetDepth: number,\n start: number,\n end: number,\n containerClass: string,\n startLine: number\n): TabsListNode => {\n const depthLabels = rawTabs\n .slice(start, end)\n .filter((t) => t.depth === targetDepth)\n .map((t) => t.labelText);\n\n const gId = groupId(depthLabels);\n const bId = blockId(startLine, gId);\n\n // Absolute index of the first %+ tab at this depth (-1 if none)\n const explicitOpenIdx = rawTabs\n .slice(start, end)\n .findIndex((t) => t.depth === targetDepth && t.open);\n const explicitOpenAbsIdx =\n explicitOpenIdx >= 0 ? start + explicitOpenIdx : -1;\n\n const items: TabsItemNode[] = [];\n let tabCounter = 0;\n let i = start;\n\n while (i < end) {\n const raw = rawTabs[i];\n if (raw.depth !== targetDepth) {\n i++;\n continue;\n }\n\n let childEnd = i + 1;\n while (childEnd < end && rawTabs[childEnd].depth > targetDepth) childEnd++;\n\n // First %+ wins; if none, first tab is open\n const isOpen =\n explicitOpenAbsIdx >= 0 ? i === explicitOpenAbsIdx : tabCounter === 0;\n const bodyChildren: TabsItemNode[\"children\"] = [...raw.body];\n\n const hasDeeper = rawTabs\n .slice(i + 1, childEnd)\n .some((t) => t.depth === targetDepth + 1);\n\n if (hasDeeper) {\n const nested = buildTree(\n rawTabs,\n targetDepth + 1,\n i + 1,\n childEnd,\n containerClass,\n startLine\n );\n nested.containerClass = containerClass;\n bodyChildren.push(nested as unknown as BlockContent);\n }\n\n items.push({\n type: \"tabsItem\",\n depth: targetDepth,\n label: raw.labelNodes,\n labelText: raw.labelText,\n open: isOpen,\n children: bodyChildren,\n data: {\n attrsRole: \"containerItem\",\n attrsTitle: raw.labelNodes,\n attrsItemTitle: true,\n hProperties: {}\n }\n });\n\n tabCounter++;\n i = childEnd;\n }\n\n return {\n type: \"tabsList\",\n depth: targetDepth,\n groupId: gId,\n blockId: bId,\n children: items,\n data: { attrsRole: \"container\", hProperties: {} }\n };\n};\n\n// ── Remark plugin ─────────────────────────────────────────────────────────────\n\n// Process all tab groups found in a children array in-place.\n// Used at root level and recursively inside any parent node's children.\n// checkBlankLines: when false, skip the line-gap termination check (for nested contexts\n// where blank lines inside blockquotes produce position gaps but are still part of the group).\nconst processTabsInChildren = (\n children: Array<BlockContent | DefinitionContent | RootContent>,\n containerClass: string,\n checkBlankLines = true\n): void => {\n const newChildren: typeof children = [];\n let i = 0;\n\n while (i < children.length) {\n const node = children[i];\n\n if (node.type === \"paragraph\") {\n const headerTabs = extractHeaderPara(node);\n\n if (headerTabs && headerTabs.length > 0) {\n const rawTabs: RawTab[] = [...headerTabs];\n const startLine = (node.position?.start.line ?? 1) - 1;\n let j = i + 1;\n let currentTabIdx = rawTabs.length - 1;\n let prevEndLine = node.position?.end.line ?? 0;\n\n while (j < children.length) {\n const sibling = children[j];\n const siblingStartLine =\n (sibling as { position?: { start: { line: number } } }).position\n ?.start.line ?? prevEndLine + 1;\n\n if (checkBlankLines && siblingStartLine > prevEndLine + 1) break;\n\n if (sibling.type === \"blockquote\") {\n const bq = sibling;\n const explicit = isExplicitBQ(bq);\n const segments = splitBlockquote(bq, explicit);\n\n const firstSeg = segments[0];\n if (firstSeg?.header === null) {\n rawTabs[currentTabIdx].body.push(...firstSeg.body);\n }\n\n // Explicit blockquotes (`> % Label` nesting) have their headers\n // implicitly one level deeper than the owning tab. Apply a depth\n // offset so they nest correctly.\n // Absorbed blockquotes (standard `% Tab\\n> body` pattern) keep\n // literal depths — remark collapses them into a single paragraph child.\n const depthOffset = explicit\n ? rawTabs[rawTabs.length - 1].depth\n : 0;\n\n for (let s = 1; s < segments.length; s++) {\n const seg = segments[s];\n if (!seg.header) continue;\n\n const adjustedDepth = depthOffset + seg.header.depth;\n const prevDepth = rawTabs[rawTabs.length - 1].depth;\n if (adjustedDepth > prevDepth + 1) continue;\n\n seg.header.depth = adjustedDepth;\n\n if (explicit) {\n // For explicit `> %` blockquotes, body items are wrapped in a\n // nested `> >` blockquote. Unwrap each nested blockquote:\n // - Non-explicit (absorbed) inner BQs are re-split to extract\n // tab headers that remark collapsed into a single paragraph.\n // - Explicit inner BQs use their children directly.\n //\n // \"Escaped\" segments: when remark absorbs an outer-level tab header\n // (e.g. `% Code` at root depth) into an inner BQ paragraph, the tab's\n // body node (code fence etc.) is hoisted to the outer BQ as a direct\n // child after that inner BQ. Re-split segments with an empty body had\n // their body hoisted — they are outer-level siblings, not inner children.\n // Subsequent non-blockquote nodes in seg.body belong to those escaped tabs.\n const deferredInnerSegs: BQSegment[] = [];\n // Tracks which re-split segments have empty bodies (body hoisted to outer BQ)\n const escapedSegs: RawTab[] = [];\n\n for (const b of seg.body) {\n if (b.type !== \"blockquote\") {\n // Non-BQ outer sibling — belongs to the first escaped seg's body\n if (escapedSegs.length > 0) {\n escapedSegs[escapedSegs.length - 1].body.push(\n b as BlockContent | DefinitionContent\n );\n } else {\n seg.header.body.push(\n b as BlockContent | DefinitionContent\n );\n }\n continue;\n }\n const innerBq = b;\n if (!isExplicitBQ(innerBq)) {\n // Re-split absorbed inner blockquote to extract sibling headers\n const innerSegs = splitBlockquote(innerBq, false);\n const innerFirst = innerSegs[0];\n if (innerFirst?.header === null) {\n seg.header.body.push(...innerFirst.body);\n }\n for (let is = 1; is < innerSegs.length; is++) {\n const innerSeg = innerSegs[is];\n if (!innerSeg.header) continue;\n // If the re-split segment has no body, its body was hoisted to\n // the outer BQ as a direct child — it is an outer-level escaped\n // tab (originally root-level, absorbed by remark into this inner BQ).\n // Push it at depthOffset (the owning explicit BQ's parent depth).\n if (innerSeg.body.length === 0) {\n innerSeg.header.depth = depthOffset;\n escapedSegs.push(innerSeg.header);\n deferredInnerSegs.push(innerSeg);\n continue;\n }\n const tentativeDepth =\n depthOffset + innerSeg.header.depth;\n const innerPrevDepth = rawTabs[rawTabs.length - 1].depth;\n if (tentativeDepth > innerPrevDepth + 1) continue;\n innerSeg.header.depth = tentativeDepth;\n innerSeg.header.body.push(...innerSeg.body);\n deferredInnerSegs.push(innerSeg);\n }\n } else {\n // Explicit inner blockquote — use children directly\n seg.header.body.push(...innerBq.children);\n }\n }\n // Push the current seg first, then any deferred inner siblings\n rawTabs.push(seg.header);\n currentTabIdx = rawTabs.length - 1;\n for (const innerSeg of deferredInnerSegs) {\n if (!innerSeg.header) continue;\n rawTabs.push(innerSeg.header);\n currentTabIdx = rawTabs.length - 1;\n }\n } else {\n seg.header.body.push(...seg.body);\n rawTabs.push(seg.header);\n currentTabIdx = rawTabs.length - 1;\n }\n }\n\n prevEndLine = sibling.position?.end.line ?? prevEndLine;\n j++;\n } else if (sibling.type === \"paragraph\") {\n const prevDepth = rawTabs[rawTabs.length - 1].depth;\n const contHeaders = extractHeaderPara(sibling, false, prevDepth);\n if (contHeaders && contHeaders.length > 0) {\n rawTabs.push(...contHeaders);\n currentTabIdx = rawTabs.length - 1;\n prevEndLine = sibling.position?.end.line ?? prevEndLine;\n j++;\n continue;\n }\n break;\n } else {\n break;\n }\n }\n\n const list = buildTree(\n rawTabs,\n 1,\n 0,\n rawTabs.length,\n containerClass,\n startLine\n );\n list.containerClass = containerClass;\n newChildren.push(list as unknown as RootContent);\n i = j;\n continue;\n }\n }\n\n newChildren.push(node);\n i++;\n }\n\n children.splice(0, children.length, ...newChildren);\n};\n\n/** remark plugin for tabbed content blocks, rendered via {@link tabsHastHandlers}. */\nexport const remarkTabs: Plugin<[TabsOptions?], Root> = function (\n options = {}\n) {\n const { containerClass = \"markdown-tabs\" } = options;\n\n return (tree) => {\n // Process tabs at root level first\n processTabsInChildren(tree.children, containerClass);\n\n // Then visit every parent node whose children may contain tab syntax —\n // this handles tabs nested inside step bodies or other block containers.\n // Blank-line position checks are disabled for nested content: blank lines\n // inside a blockquote produce position gaps that would incorrectly terminate\n // a tab group when the content has been lifted out of its blockquote context.\n visit(tree, (node) => {\n if (\"children\" in node && node.type !== \"root\") {\n const parent = node as {\n children: Array<BlockContent | DefinitionContent>;\n };\n if (parent.children.length > 0) {\n processTabsInChildren(parent.children, containerClass, false);\n }\n }\n });\n };\n};\n\n// ── HAST handlers ─────────────────────────────────────────────────────────────\n\nconst mergeHProperties = (base: Properties, extra?: Properties): Properties => {\n if (!extra) return base;\n const { class: extraClass, ...rest } = extra;\n const result: Properties = { ...base, ...rest };\n if (extraClass)\n result.class = base.class\n ? `${String(base.class)} ${String(extraClass)}`\n : extraClass;\n return result;\n};\n\nconst buildTabsHast = (\n list: TabsListNode,\n containerClass: string,\n state: State\n): Element => {\n const labelChildren: ElementContent[] = [];\n const panelChildren: ElementContent[] = [];\n\n list.children.forEach((item, idx) => {\n const labelPlain = stripAttrs(item.labelText);\n const inputId = `${list.blockId}-${idx}`;\n\n // <input type=\"radio\">\n const inputProps: Properties = {\n type: \"radio\",\n name: list.blockId,\n id: inputId,\n hidden: true,\n ...(item.open ? { checked: true } : {})\n };\n labelChildren.push({\n type: \"element\",\n tagName: \"input\",\n properties: inputProps,\n children: []\n });\n\n // <label>\n const labelProps = mergeHProperties(\n { class: `${containerClass}-label`, for: inputId },\n item.data?.hProperties\n );\n labelChildren.push({\n type: \"element\",\n tagName: \"label\",\n properties: labelProps,\n children: state.all({\n type: \"paragraph\",\n children: item.label\n } as Parameters<typeof state.all>[0])\n });\n\n // Panel body and nested lists\n const bodyBlocks = item.children.filter(\n (c) => (c as { type: string }).type !== \"tabsList\"\n );\n const nestedLists = item.children.filter(\n (c) => (c as { type: string }).type === \"tabsList\"\n ) as unknown as TabsListNode[];\n\n const sectionChildren: ElementContent[] = [];\n\n if (bodyBlocks.length > 0) {\n sectionChildren.push(\n ...state.all({\n type: \"root\",\n children: bodyBlocks\n } as Parameters<typeof state.all>[0])\n );\n }\n\n for (const nested of nestedLists) {\n sectionChildren.push(\n buildTabsHast(nested, nested.containerClass ?? containerClass, state)\n );\n }\n\n // <section>\n const sectionProps = mergeHProperties(\n { class: `${containerClass}-panel`, \"aria-label\": labelPlain },\n undefined\n );\n panelChildren.push({\n type: \"element\",\n tagName: \"section\",\n properties: sectionProps,\n children: sectionChildren\n });\n });\n\n // <div class=\"...-labels\">\n const labelsDiv: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: { class: `${containerClass}-labels` },\n children: labelChildren\n };\n\n // <div class=\"...-panels\">\n const panelsDiv: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: { class: `${containerClass}-panels` },\n children: panelChildren\n };\n\n // <div> container\n const divProps = mergeHProperties(\n { class: containerClass, \"data-tabs-group\": list.groupId },\n list.data?.hProperties\n );\n\n const result: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: divProps,\n children: [labelsDiv, panelsDiv]\n };\n\n state.patch(list as unknown as Parameters<typeof state.patch>[0], result);\n return result;\n};\n\n/** mdast-to-hast handler for tabs nodes, for use with `remark-rehype`. */\nexport const tabsHastHandlers: Record<string, Handler> = {\n tabsList(state: State, node: TabsListNode): ElementContent {\n const containerClass = node.containerClass ?? \"markdown-tabs\";\n return buildTabsHast(node, containerClass, state);\n }\n};\n"],"mappings":";;AAEA,MAAa,gBAAgB;AAW7B,MAAa,kBAAkB,SAAyC;CACtE,MAAM,IAAI,cAAc,KAAK,KAAK;AAClC,KAAI,CAAC,EAAG,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B,MAAM;EACN,SAAS;EACT,YARe,iBACf;GAAE,OAAO;GAAgB,mBAAmB,KAAK;GAAS,EAC1D,KAAK,MAAM,YAMS;EACpB,UAAU,CAAC,WAAW,UAAU;EACjC;AAED,OAAM,MAAM,MAAsD,OAAO;AACzE,QAAO;;;AAIT,MAAa,mBAA4C,EACvD,SAAS,OAAc,MAAoC;AAEzD,QAAO,cAAc,MADE,KAAK,kBAAkB,iBACH,MAAM;GAEpD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["// The hast handlers bridge mdast/hast types that don't unify cleanly; the assertions are reviewed and intentional.\n/* oxlint-disable typescript/no-unsafe-type-assertion */\nimport type { Plugin } from \"unified\";\nimport type { Root } from \"mdast\";\nimport type { Element, ElementContent, Properties } from \"hast\";\nimport type { State, Handler } from \"mdast-util-to-hast\";\nimport {\n processTabs,\n stripAttrs,\n tabLabelText,\n tabsBlockId,\n type TabsLabelNode\n} from \"@mirrordown/core\";\nimport type { TabsOptions, TabsListNode } from \"./types.js\";\n\nexport type { TabsOptions };\n\n/** remark plugin for tabbed content blocks, rendered via {@link tabsHastHandlers}. */\nexport const remarkTabs: Plugin<[TabsOptions?], Root> = function (\n options = {}\n) {\n const { containerClass = \"markdown-tabs\" } = options;\n\n // Recognition is shared with the Sätteri plugin through `@mirrordown/core`; it also finds tabs nested inside step bodies and other block containers.\n return (tree, file) => {\n processTabs(tree, containerClass, String(file));\n };\n};\n\n// ── HAST handlers ─────────────────────────────────────────────────────────────\n\nconst mergeHProperties = (base: Properties, extra?: Properties): Properties => {\n if (!extra) return base;\n const { class: extraClass, ...rest } = extra;\n const result: Properties = { ...base, ...rest };\n if (extraClass)\n result.class = base.class\n ? `${String(base.class)} ${String(extraClass)}`\n : extraClass;\n return result;\n};\n\n// Each document's tab groups, counted as they render (in the order they open), for their block ids.\nconst groupsRendered = new WeakMap<State, number>();\n\nconst buildTabsHast = (\n list: TabsListNode,\n containerClass: string,\n state: State\n): Element => {\n const index = groupsRendered.get(state) ?? 0;\n groupsRendered.set(state, index + 1);\n const blockId = tabsBlockId(index, list.groupId);\n const labelChildren: ElementContent[] = [];\n const panelChildren: ElementContent[] = [];\n\n list.children.forEach((item, idx) => {\n const label =\n item.children.find((c): c is TabsLabelNode => c.type === \"tabsLabel\")\n ?.children ?? [];\n // From the label as it is now, so plugins that ran after tabs count too.\n const labelPlain = stripAttrs(tabLabelText(label));\n const inputId = `${blockId}-${idx}`;\n\n // <input type=\"radio\">\n const inputProps: Properties = {\n type: \"radio\",\n name: blockId,\n id: inputId,\n hidden: true,\n ...(item.open ? { checked: true } : {})\n };\n labelChildren.push({\n type: \"element\",\n tagName: \"input\",\n properties: inputProps,\n children: []\n });\n\n // <label>\n const labelProps = mergeHProperties(\n { class: `${containerClass}-label`, for: inputId },\n item.data?.hProperties\n );\n labelChildren.push({\n type: \"element\",\n tagName: \"label\",\n properties: labelProps,\n children: state.all({\n type: \"paragraph\",\n children: label\n })\n });\n\n // Panel body and nested lists\n // The panel's body and nested groups, in order: content can follow a nested group.\n const sectionChildren: ElementContent[] = [];\n let blocks: typeof item.children = [];\n const flush = (): void => {\n if (blocks.length > 0) {\n sectionChildren.push(\n ...state.all({\n type: \"root\",\n children: blocks\n })\n );\n }\n blocks = [];\n };\n for (const child of item.children) {\n if (child.type === \"tabsLabel\") continue;\n if (child.type === \"tabsList\") {\n flush();\n sectionChildren.push(\n buildTabsHast(child, child.containerClass ?? containerClass, state)\n );\n } else {\n blocks.push(child);\n }\n }\n flush();\n\n // <section>\n const sectionProps = mergeHProperties(\n { class: `${containerClass}-panel`, \"aria-label\": labelPlain },\n undefined\n );\n panelChildren.push({\n type: \"element\",\n tagName: \"section\",\n properties: sectionProps,\n children: sectionChildren\n });\n });\n\n // <div class=\"...-labels\">\n const labelsDiv: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: { class: `${containerClass}-labels` },\n children: labelChildren\n };\n\n // <div class=\"...-panels\">\n const panelsDiv: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: { class: `${containerClass}-panels` },\n children: panelChildren\n };\n\n // <div> container\n const divProps = mergeHProperties(\n { class: containerClass, \"data-tabs-group\": list.groupId },\n list.data?.hProperties\n );\n\n const result: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: divProps,\n children: [labelsDiv, panelsDiv]\n };\n\n state.patch(list, result);\n return result;\n};\n\n/** mdast-to-hast handler for tabs nodes, for use with `remark-rehype`. */\nexport const tabsHastHandlers: Record<string, Handler> = {\n tabsList(state: State, node: TabsListNode): ElementContent {\n const containerClass = node.containerClass ?? \"markdown-tabs\";\n return buildTabsHast(node, containerClass, state);\n }\n};\n"],"mappings":";;;AAkBA,MAAa,aAA2C,SACtD,UAAU,CAAC,GACX;CACA,MAAM,EAAE,iBAAiB,oBAAoB;CAG7C,QAAQ,MAAM,SAAS;EACrB,YAAY,MAAM,gBAAgB,OAAO,IAAI,CAAC;CAChD;AACF;AAIA,MAAM,oBAAoB,MAAkB,UAAmC;CAC7E,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,EAAE,OAAO,YAAY,GAAG,SAAS;CACvC,MAAM,SAAqB;EAAE,GAAG;EAAM,GAAG;CAAK;CAC9C,IAAI,YACF,OAAO,QAAQ,KAAK,QAChB,GAAG,OAAO,KAAK,KAAK,EAAE,GAAG,OAAO,UAAU,MAC1C;CACN,OAAO;AACT;AAGA,MAAM,iCAAiB,IAAI,QAAuB;AAElD,MAAM,iBACJ,MACA,gBACA,UACY;CACZ,MAAM,QAAQ,eAAe,IAAI,KAAK,KAAK;CAC3C,eAAe,IAAI,OAAO,QAAQ,CAAC;CACnC,MAAM,UAAU,YAAY,OAAO,KAAK,OAAO;CAC/C,MAAM,gBAAkC,CAAC;CACzC,MAAM,gBAAkC,CAAC;CAEzC,KAAK,SAAS,SAAS,MAAM,QAAQ;EACnC,MAAM,QACJ,KAAK,SAAS,MAAM,MAA0B,EAAE,SAAS,WAAW,CAAC,EACjE,YAAY,CAAC;E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AY,EAAE,OAAO,GAAG,eAAe,SAAS;EAChD,UAAU;CACZ;CAQA,MAAM,SAAkB;EACtB,MAAM;EACN,SAAS;EACT,YARe,iBACf;GAAE,OAAO;GAAgB,mBAAmB,KAAK;EAAQ,GACzD,KAAK,MAAM,WAMQ;EACnB,UAAU,CAAC,WAAW,SAAS;CACjC;CAEA,MAAM,MAAM,MAAM,MAAM;CACxB,OAAO;AACT;;AAGA,MAAa,mBAA4C,EACvD,SAAS,OAAc,MAAoC;CACzD,MAAM,iBAAiB,KAAK,kBAAkB;CAC9C,OAAO,cAAc,MAAM,gBAAgB,KAAK;AAClD,EACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirrordown/remd-tabs",
|
|
3
3
|
"description": "A remark plugin for tabbed content blocks.",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
|
|
7
7
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"./*.css": "./dist/*.css"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"
|
|
25
|
+
"@mirrordown/core": "^0.1.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/hast": "^3.0.4",
|