@mirrordown/remd-tabs 0.0.0 → 0.1.0

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/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # @mirrordown/remd-tabs
2
+
3
+ > Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified and markdown-it ecosystems.
4
+
5
+ A remark/rehype (unified) plugin for the `tabs` syntax extension.
6
+
7
+ ## Overview
8
+
9
+ The `tabs` plugin converts `%`-prefixed headers and `>`-prefixed blockquote bodies into CSS-only tab groups. Tabs use hidden radio inputs for state — no JavaScript required.
10
+
11
+ ```html
12
+ <div class="markdown-tabs" data-tabs-group="...">
13
+ <div class="markdown-tabs-labels">...</div>
14
+ <div class="markdown-tabs-panels">...</div>
15
+ </div>
16
+ ```
17
+
18
+ ## Syntax
19
+
20
+ Write a `% Label` line followed by a `>` blockquote for each tab's content:
21
+
22
+ ````markdown
23
+ % JavaScript
24
+
25
+ > ```js
26
+ > console.log("Hello, world!");
27
+ > ```
28
+ >
29
+ > % TypeScript
30
+ >
31
+ > ```ts
32
+ > const greeting: string = "Hello, world!";
33
+ > console.log(greeting);
34
+ > ```
35
+ >
36
+ > % Python
37
+ >
38
+ > ```py
39
+ > print("Hello, world!")
40
+ > ```
41
+ ````
42
+
43
+ ### Default open tab
44
+
45
+ Mark a tab with `%+` to make it open by default (the first tab is open by default otherwise):
46
+
47
+ ```markdown
48
+ % Option A
49
+
50
+ > This tab is not selected by default.
51
+ > %+ Option B
52
+ > This tab opens by default.
53
+ > % Option C
54
+ > This tab is not selected by default.
55
+ ```
56
+
57
+ ### Nested tabs
58
+
59
+ Use `%%` for a second level of nesting inside a tab:
60
+
61
+ ````markdown
62
+ % Frontend
63
+ %% React
64
+
65
+ > ```tsx
66
+ > export function App() {
67
+ > return <h1>Hello</h1>;
68
+ > }
69
+ > ```
70
+ >
71
+ > %% Vue
72
+ >
73
+ > ```vue
74
+ > <template><h1>Hello</h1></template>
75
+ > ```
76
+ >
77
+ > % Backend
78
+ > Node.js or any server runtime.
79
+ ````
80
+
81
+ ## Install
82
+
83
+ Install `@mirrordown/remd-tabs`. You must also pass `tabsHastHandlers` to `remarkRehype` and import the stylesheet:
84
+
85
+ ```sh
86
+ npm install @mirrordown/remd-tabs
87
+ ```
88
+
89
+ ### Unified
90
+
91
+ ```ts
92
+ import { unified } from "unified";
93
+ import remarkParse from "remark-parse";
94
+ import remarkRehype from "remark-rehype";
95
+ import rehypeStringify from "rehype-stringify";
96
+ import { remarkTabs, tabsHastHandlers } from "@mirrordown/remd-tabs";
97
+ import "@mirrordown/remd-tabs/tabs.css";
98
+
99
+ const processor = unified()
100
+ .use(remarkParse)
101
+ .use(remarkTabs)
102
+ .use(remarkRehype, { handlers: tabsHastHandlers })
103
+ .use(rehypeStringify);
104
+ ```
105
+
106
+ ### Astro
107
+
108
+ ```ts
109
+ // astro.config.ts
110
+ import { defineConfig } from "astro/config";
111
+ import { remarkTabs, tabsHastHandlers } from "@mirrordown/remd-tabs";
112
+ import "@mirrordown/remd-tabs/tabs.css";
113
+
114
+ export default defineConfig({
115
+ markdown: {
116
+ 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
+ }
135
+ });
136
+ ```
137
+
138
+ ## Documentation
139
+
140
+ Full documentation, more examples, and configuration options: [github.com/mirrordown/mirrordown](https://github.com/mirrordown/mirrordown) (dedicated docs site coming soon).
141
+
142
+ ## License
143
+
144
+ MIT © [Drake Costa](https://saeris.gg)