@mirrordown/remd-tabs 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,266 @@
6
6
 
7
7
 
8
8
 
9
+
10
+
11
+ ## 0.2.4
12
+ <sub>2026-11-17</sub>
13
+
14
+ - *(patch)*
15
+ Fixes for edge cases where the three engines read `% Tab` headers and their `>` panels differently; the first one changes what markdown-it renders for a panel, inside another block, that holds a blank line written without `>`.
16
+
17
+ - **Inside a list item, blockquote or step, a blank line without `>` in a panel ends the blocks before it** (markdown-it).
18
+
19
+ ```markdown
20
+ - % A
21
+ > - a
22
+
23
+ > - b
24
+ ```
25
+
26
+ Was one loose list in the panel, `<ul><li><p>a</p></li><li><p>b</p></li></ul>`. Now two lists, `<ul><li>a</li></ul><ul><li>b</li></ul>`, as in remark and Sätteri. This can change an existing document: a list or a code fence in such a panel no longer continues across the blank line (a fence ends there, and the lines after it are read as new blocks). Write the blank line as a lone `>` to keep the list or fence together, which works in every engine. A panel made of paragraphs renders as before, and at the top level of a document a blank line ends the tabs, as it always did.
27
+
28
+ - **A header ends at the end of its line: a trailing backslash or trailing spaces make no line break** (all engines).
29
+
30
+ ```markdown
31
+ % A\
32
+ % B
33
+ > Body.
34
+ ```
35
+
36
+ Was, in remark and Sätteri, the paragraph `<p>% A<br></p>` followed by a group holding only B. Now one group with the labels `A\` and `B`, as in markdown-it. Two trailing spaces did the same and are now dropped; markdown-it used to keep a header's trailing spaces in the label and its `aria-label`, and read `%` followed only by a space as a tab with an empty label (it is now the text `%`). A panel line directly before a header no longer ends in `<br>` either.
37
+
38
+ - **A line that is neither a header nor a `>` line ends the tabs wherever it is written** (remark, Sätteri).
39
+
40
+ ```markdown
41
+ % A
42
+ text
43
+ ```
44
+
45
+ Was the paragraph `<p>% A\ntext</p>`, with no tabs. Now a group with the tab A, followed by `<p>text</p>`, as in markdown-it.
46
+
47
+ - **Such a line between a panel and the next header ends the group there** (remark, Sätteri).
48
+
49
+ ```markdown
50
+ % A
51
+ > a
52
+ text
53
+ % B
54
+ > b
55
+ ```
56
+
57
+ Was one group, with `text` in A's panel. Now a group holding A, then `<p>text</p>`, then a second group holding B, as in markdown-it. Directly after a header that follows a panel (`% Two` then `text`), the line was that tab's panel and now follows the group.
58
+
59
+ - **Every line of a nested tab's panel stays in the panel** (remark, Sätteri).
60
+
61
+ ```markdown
62
+ % A
63
+ %% B
64
+ > one
65
+ > two
66
+ ```
67
+
68
+ Was `one` in B's panel and `two` moved out of it, into A's. Now `<p>one\ntwo</p>` in B's panel, as in markdown-it.
69
+
70
+ - **The lines after the tabs are read as the blocks they are written as** (remark, Sätteri).
71
+
72
+ ```markdown
73
+ % One
74
+ > First
75
+ After
76
+ > quoted
77
+ ```
78
+
79
+ Was `<p>After\nquoted</p>` after the group. Now `<p>After</p><blockquote><p>quoted</p></blockquote>`, as in markdown-it. With the steps plugin, a tab group written directly under a step's body (`@1. A`, `> body`, `% Tab`, `> t`) is recognised for the same reason; it was the text `% Tab\nt`.
80
+
81
+ - **A header is found after emphasis, a code span or a link that spans lines** (remark, Sätteri).
82
+
83
+ ```markdown
84
+ % A
85
+ > *emph
86
+ > more* text
87
+ % B
88
+ > b
89
+ ```
90
+
91
+ Was `<p>% B\nb</p>` at the end of A's panel. Now B is the group's second tab, as in markdown-it.
92
+
93
+ - **Carriage returns never reach the output** (remark, Sätteri). In a document with CRLF line endings, a panel paragraph followed by a header ended in a carriage return. It now renders as it does with LF.
94
+
95
+ - **Tabs in a list item end where the item ends** (markdown-it).
96
+
97
+ ```markdown
98
+ - % One
99
+ > First.
100
+ ```
101
+
102
+ Was `First.` as the tab's panel, inside the item. Now the item holds the tab and `<blockquote><p>First.</p></blockquote>` follows the list, as in remark and Sätteri. A header written outside the item after a blank line likewise starts a group of its own instead of becoming the item's next tab.
103
+
104
+ - **A header written in a list item after text starts tabs** (remark, Sätteri).
105
+
106
+ ```markdown
107
+ - text
108
+ % A
109
+ > a
110
+ ```
111
+
112
+ Was the text `% A` and a blockquote. Now `<li>text` followed by the tabs, as in markdown-it.
113
+
114
+ - **A line written short of a list item's content continues the item** (markdown-it).
115
+
116
+ ```markdown
117
+ - item
118
+ % A
119
+ ```
120
+
121
+ Was a list followed by a tab group. Now `<li>item\n% A</li>`, as in remark and Sätteri and as CommonMark reads the line; indent the header to the item's content to start tabs there. In the same way `para` after `- % A` and ` > a` was a paragraph after the list and is now text in the item, after the tabs.
122
+
123
+ - **Inside a list item or blockquote, tabs that a plain line ended are not continued after a blank line** (remark, Sätteri).
124
+
125
+ ```markdown
126
+ - % A
127
+ > a
128
+ text
129
+
130
+ % B
131
+ > b
132
+ ```
133
+
134
+ Was one group, with `text` in A's panel and B as its second tab. Now a group holding A, `<p>text</p>`, and a second group holding B, as in markdown-it.
135
+
136
+ - **A `>` indented four columns or more is not a panel line** (all engines).
137
+
138
+ ```markdown
139
+ % A
140
+ > Body.
141
+ ```
142
+
143
+ Was a tab with the panel `<p>Body.</p>` in markdown-it, and the paragraph `<p>% A\n> Body.</p>` with no tabs in remark and Sätteri. Now the tab A with an empty panel, followed by `<p>> Body.</p>`, in every engine. In markdown-it, such a line after a panel line stays in the panel as the text `> b`, and after a blank `>` line it is indented code after the tabs.
144
+
145
+ - **A header indented four columns or more after text continues the paragraph** (remark, Sätteri).
146
+
147
+ ```markdown
148
+ text
149
+ % A
150
+ ```
151
+
152
+ Was `<p>text</p>` followed by a tab group. Now `<p>text\n% A</p>`, as in markdown-it.
153
+
154
+ - **An escaped header is text** (remark, Sätteri).
155
+
156
+ ```markdown
157
+ \% A
158
+ > b
159
+ ```
160
+
161
+ Was a tab A with the panel `b`. Now `<p>% A</p><blockquote><p>b</p></blockquote>`, as in markdown-it. In remark `%\+ A` and `&#37; A` were tabs too, and are now text.
162
+
163
+ - **A label that links through a reference definition gives the same `aria-label` and ids as its text** (markdown-it).
164
+
165
+ ```markdown
166
+ % [text][foo]
167
+ > Body.
168
+
169
+ [foo]: https://example.com
170
+ ```
171
+
172
+ Was `aria-label="[text][foo]"`, with a `data-tabs-group` and input ids built from that bracketed text. Now `aria-label="text"` and the ids remark and Sätteri give, which are those of a tab labelled `text`.
173
+
174
+ - **Tab groups are numbered in the order they are written** (markdown-it, remark). A group's input `name` and `id` include its place among the document's groups, and the engines counted it differently when a group sits in a footnote definition (remark counted it last) or in a `prompt` block's preview (markdown-it counted it last).
175
+
176
+ ````markdown
177
+ ```prompt
178
+ % A
179
+ > a
180
+ ```
181
+
182
+ % B
183
+ > b
184
+ ````
185
+
186
+ Was `name="tabs-4aafe540"` for A and `name="tabs-fdb5a880"` for B in markdown-it. Now `tabs-fdb5a87f` and `tabs-4aafe541`, the ids these two groups have without the prompt block around the first, and the same ids in every engine.
187
+
188
+ - **`md.parse(src)` without an `env` no longer throws** (markdown-it).
189
+
190
+ - **A code fence left open at the end of a panel keeps its last line ending** (markdown-it).
191
+
192
+ ````markdown
193
+ % A
194
+ > ```
195
+ > code
196
+ % B
197
+ > b
198
+ ````
199
+
200
+ Was `<code>code</code>`. Now `<code>code\n</code>`, as in remark and Sätteri.
201
+
202
+ - **A tab character after a panel's `>` is the marker's space** (markdown-it). A panel line written as `>`, a tab character, then text was indented code; it is now a paragraph, as in remark and Sätteri.
203
+
204
+ - **A line without any `>` after tabs in a blockquote leaves the blockquote** (remark, Sätteri).
205
+
206
+ ```markdown
207
+ > % A
208
+ > > body
209
+ plain
210
+ ```
211
+
212
+ Was `<p>plain</p>` inside the blockquote, after the group. Now after the blockquote, as in markdown-it.
213
+
214
+ - **A tab header in a sub-step's body starts tabs** (remark, Sätteri), with the steps plugin.
215
+
216
+ ```markdown
217
+ @1. A
218
+ @@1. B
219
+ > text
220
+ > % Tab
221
+ > > body
222
+ ```
223
+
224
+ Was `<p>text\n% Tab</p>` and a blockquote in the sub-step's body. Now `<p>text</p>` followed by the tab group, as in markdown-it.
225
+
226
+ - **An attribute block on its own line after the tabs goes on the group** (Sätteri).
227
+
228
+ ```markdown
229
+ % A
230
+ > a
231
+ {.x}
232
+ ```
233
+
234
+ Was dropped. Now `<div class="markdown-tabs x" …>`, as in markdown-it and remark.
235
+
236
+ - **An attribute block on its own line after content that ended the tabs goes on that content** (remark, Sätteri).
237
+
238
+ ```markdown
239
+ % A
240
+ > a
241
+ text
242
+ > q
243
+ {.x}
244
+ ```
245
+
246
+ Was `<p class="x">text\nq</p>` in remark and the same paragraph without the class in Sätteri. Now `<p>text</p><blockquote class="x"><p>q</p></blockquote>`, as in markdown-it.
247
+
248
+ - **Attributes on a panel line under a header that follows a nested quote are kept** (Sätteri).
249
+
250
+ ```markdown
251
+ % A
252
+ > > x
253
+ % B
254
+ > b {.y}
255
+ ```
256
+
257
+ Was `<p>b</p>` in B's panel. Now `<p class="y">b</p>`, as in markdown-it and remark.
258
+
259
+ - **`remd-tabs` joins a `className` set by another plugin with the element's own class.** An element given `data.hProperties.className` rendered two `class` attributes, and browsers ignore the second.
260
+
261
+ The guide's "Things to know" section lists the differences between engines that remain.
262
+
263
+ ## 0.2.3
264
+ <sub>2026-11-03</sub>
265
+
266
+ - *(patch)*
267
+ Clip tabs to their rounded corners with `overflow: clip` rather than `hidden`, so they're no longer a scroll container: sticky content in a panel, such as a file tree's folder rows, now sticks to the page. `display: flow-root` keeps floats in a panel contained, as before.
268
+
9
269
  ## 0.2.2
10
270
  <sub>2026-10-28</sub>
11
271
 
package/README.md CHANGED
@@ -68,9 +68,27 @@ Use `%%` for a second level of nesting inside a tab:
68
68
  > Node.js or any server runtime.
69
69
  ````
70
70
 
71
+ ### Things to know
72
+
73
+ - Every line of a panel starts with `>`. A line that is neither a header nor a `>` line ends the tabs, and so does a blank line at the top level of the document.
74
+ - A blank line inside a panel needs the panel's `>`. Inside another block (a blockquote, a list item, a step), a blank line written without it ends the blocks before it (a list or a code fence does not continue across it), though the panel itself goes on with the next `>` line.
75
+ - A header is one line. Spaces at its end are not part of the label and make no line break, and a backslash at its end is a literal backslash.
76
+ - Tabs nest six levels deep (`%%%%%%`), one level at a time. A header that skips a level (`%%%` under `%`) or has more than six `%` is not a header.
77
+ - In a list item, write headers at the indentation of the item's content: a line written short of it continues the paragraph before it as text, as it does in CommonMark, whether it is a header or not. Where no paragraph is open for it to continue (after a code fence, say), such a line ends the item.
78
+ - In a blockquote, a line written without any `>` leaves the blockquote. Between two tabs, markdown-it ends the blockquote at that line and starts another for the tabs after it, while remark and Sätteri keep the line and those tabs in the one blockquote.
79
+ - Directly after a header, write a `>` line, another header or a blank line. remark and Sätteri read any other line as CommonMark does, together with the header: a `===` or `---` underline makes the header a heading, and a line that cannot interrupt a paragraph (a list item numbered other than 1, indented code, a link reference definition) stays text after the tabs. markdown-it reads the header first, so there the tabs end and the line is read on its own (as a list, code, a definition, a thematic break).
80
+ - With the steps plugin, leave a blank line between a tab group and a step header after it: directly under the last panel, the header starts steps in markdown-it and stays text in remark and Sätteri.
81
+ - An alert in a panel is written as a nested quote (`> > [!NOTE]`). Directly under a header, `> [!NOTE]` is the first line of the panel, as text. In remark and Sätteri that needs the alerts plugin listed after this one, as the presets list it: listed before, it has already made the quote an alert, which then follows the tabs.
82
+ - With the [`attrs`](/guide/plugins/attrs) plugin, attributes at the end of a header go on its label, and a block on the line after the tabs goes on the group. After a blank line, markdown-it and remark still put that block on the group, while Sätteri reads it as an empty paragraph of its own.
83
+ - A `>` indented four columns or more is not a panel's marker, as it is no blockquote's in CommonMark: the line continues the paragraph before it as text (directly after a header, that ends the tabs), and after a blank line it is indented code.
84
+ - A group's ids (the `name` and `id` of its inputs, the `for` of its labels) are unique per document, not per page. They are built from the group's labels and its place among the document's groups, so two documents rendered into one page repeat them where the same labels appear in the same place.
85
+ - The stylesheet targets the default container class, `markdown-tabs`. With another `containerClass` the tabs are yours to style, and the tab-icons plugin needs the same value.
86
+ - The stylesheet shows the selected tab's panel with a rule per tab position, written out for twelve tabs: keep a group to twelve or fewer.
87
+ - `remarkTabs` reads each line's `>` markers from the file's source, so it needs a tree parsed from that same file with positions, as `remark-parse` produces.
88
+
71
89
  ## Install
72
90
 
73
- Install `@mirrordown/remd-tabs`. You must also pass `tabsHastHandlers` to `remarkRehype` and import the stylesheet:
91
+ Install `@mirrordown/remd-tabs`. You must also pass `tabsHastHandlers` to `remarkRehype` and import the stylesheet. List it after the plugins for inline syntax (del, mark and so on), so a group's `data-tabs-group` is built from its labels' text rather than their markup, and before the alerts plugin:
74
92
 
75
93
  ```sh
76
94
  npm install @mirrordown/remd-tabs
@@ -1 +1 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CxDhD,YAAY;;;;EAI3B;;;;EAKA,OAAO;;;;;UAMQ,gBAAgB;;;YAIrB;;;;;;IAMR;;YAGQ;;;;IAIR,KAAK;;YAGG;;;;IAIR,KAAK;;;;;YAMG;;;;;;;;IAQR,YAAY;;;;;;;;IASZ;;;;;;;;IASA,cAAc;;;;qBCzEL,YAAY,QAAQ,eAAe;;qBAuJnC,kBAAkB,eAAe"}
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;;;;;;;;;;;;;;;;;;;;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AAgB;;;YAIrB;;;;;;IAMR;;YAGQ;;;;IAIR,KAAK;;YAGG;;;;IAIR,KAAK;;;;;YAMG;;;;;;;;IAQR,YAAY;;;;;;;;IASZ;;;;;;;;IASA,cAAc;;;;qBC1EL,YAAY,QAAQ,eAAe;;qBAsJnC,kBAAkB,eAAe"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { processTabs, stripAttrs, tabLabelText, tabsBlockId } from "@mirrordown/core";
1
+ import { processTabs, stripAttrs, tabLabelText } from "@mirrordown/core";
2
2
  // src/plugin.ts
3
3
  /** remark plugin for tabbed content blocks, rendered via {@link tabsHastHandlers}. */
4
4
  const remarkTabs = function(options = {}) {
@@ -9,19 +9,21 @@ const remarkTabs = function(options = {}) {
9
9
  };
10
10
  const mergeHProperties = (base, extra) => {
11
11
  if (!extra) return base;
12
- const { class: extraClass, ...rest } = extra;
12
+ const { class: extraClass, className: extraClassName, ...rest } = extra;
13
13
  const result = {
14
14
  ...base,
15
15
  ...rest
16
16
  };
17
- if (extraClass) result.class = base.class ? `${String(base.class)} ${String(extraClass)}` : extraClass;
17
+ const classes = [
18
+ base.class,
19
+ extraClass,
20
+ extraClassName
21
+ ].flat().filter((value) => typeof value === "string" && value !== "");
22
+ if (classes.length > 0) result.class = classes.join(" ");
18
23
  return result;
19
24
  };
20
- const groupsRendered = /* @__PURE__ */ new WeakMap();
21
25
  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);
26
+ const { blockId } = list;
25
27
  const labelChildren = [];
26
28
  const panelChildren = [];
27
29
  list.children.forEach((item, idx) => {
@@ -1 +1 @@
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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AM;IACN,UAAU;GACZ,CAAC;EACH,CAAC;EAID,MAAM,kBAAoC,CAAC;EAC3C,IAAI,SAA+B,CAAC;EACpC,MAAM,cAAoB;GACxB,IAAI,OAAO,SAAS,GAClB,gBAAgB,KACd,GAAG,MAAM,IAAI;IACX,MAAM;IACN,UAAU;GACZ,CAAC,CACH;GAEF,SAAS,CAAC;EACZ;EACA,KAAK,MAAM,SAAS,KAAK,UAAU;GACjC,IAAI,MAAM,SAAS,aAAa;GAChC,IAAI,MAAM,SAAS,YAAY;IAC7B,MAAM;IACN,gBAAgB,KACd,cAAc,OAAO,MAAM,kBAAkB,gBAAgB,KAAK,CACpE;GACF,OACE,OAAO,KAAK,KAAK;EAErB;EACA,MAAM;EAGN,MAAM,eAAe,iBACnB;GAAE,OAAO,GAAG,eAAe;GAAS,cAAc;EAAW,GAC7D,KAAA,CACF;EACA,cAAc,KAAK;GACjB,MAAM;GACN,SAAS;GACT,YAAY;GACZ,UAAU;EACZ,CAAC;CACH,CAAC;CAGD,MAAM,YAAqB;EACzB,MAAM;EACN,SAAS;EACT,YAAY,EAAE,OAAO,GAAG,eAAe,SAAS;EAChD,UAAU;CACZ;CAGA,MAAM,YAAqB;EACzB,MAAM;EACN,SAAS;EACT,YAAY,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"}
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 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 // An author class joins the element's own, whether it's spelled `class` (attrs) or `className` (hast, and most remark plugins), as in the Sätteri plugin.\n const { class: extraClass, className: extraClassName, ...rest } = extra;\n const result: Properties = { ...base, ...rest };\n const classes = [base.class, extraClass, extraClassName]\n .flat()\n .filter(\n (value): value is string => typeof value === \"string\" && value !== \"\"\n );\n if (classes.length > 0) result.class = classes.join(\" \");\n return result;\n};\n\nconst buildTabsHast = (\n list: TabsListNode,\n containerClass: string,\n state: State\n): Element => {\n // Set at recognition, in document order: groups don't always render in that order (footnote definitions render last).\n const { blockId } = list;\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":";;;AAiBA,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;CAEnB,MAAM,EAAE,OAAO,YAAY,WAAW,gBAAgB,GAAG,SAAS;CAClE,MAAM,SAAqB;EAAE,GAAG;EAAM,GAAG;CAAK;CAC9C,MAAM,UAAU;EAAC,KAAK;EAAO;EAAY;CAAc,CAAC,CACrD,KAAK,CAAC,CACN,QACE,UAA2B,OAAO,UAAU,YAAY,UAAU,EACrE;CACF,IAAI,QAAQ,SAAS,GAAG,OAAO,QAAQ,QAAQ,KAAK,GAAG;CACvD,OAAO;AACT;AAEA,MAAM,iBACJ,MACA,gBACA,UACY;CAEZ,MAAM,EAAE,YAAY;CACpB,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;EAEnB,MAAM,aAAa,WAAW,aAAa,KAAK,CAAC;EACjD,MAAM,UAAU,GAAG,QAAQ,GAAG;EAG9B,MAAM,aAAyB;GAC7B,MAAM;GACN,MAAM;GACN,IAAI;GACJ,QAAQ;GACR,GAAI,KAAK,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;EACvC;EACA,cAAc,KAAK;GACjB,MAAM;GACN,SAAS;GACT,YAAY;GACZ,UAAU,CAAC;EACb,CAAC;EAGD,MAAM,aAAa,iBACjB;GAAE,OAAO,GAAG,eAAe;GAAS,KAAK;EAAQ,GACjD,KAAK,MAA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gB,KAAK;AAClD,EACF"}
package/dist/tabs.css CHANGED
@@ -62,7 +62,9 @@
62
62
  border: 1px solid var(--_tabs-border);
63
63
  border-radius: var(--_tabs-radius);
64
64
  background: var(--_tabs-bg);
65
- overflow: hidden;
65
+ /* Clipped to the rounded corners rather than hidden, which would make it a scroll container: sticky content inside, such as a file tree's folder rows, would stick to it instead of the page. flow-root keeps the floats inside that overflow: hidden contained. */
66
+ display: flow-root;
67
+ overflow: clip;
66
68
  }
67
69
 
68
70
  /* ── Label strip ────────────────────────────────────────────────────────── */
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.2.2",
4
+ "version": "0.2.4",
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
- "@mirrordown/core": "^0.1.2"
25
+ "@mirrordown/core": "^0.2.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/hast": "^3.0.4",