rehype-instui-markdown 0.0.7 → 0.0.9

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.
Files changed (2) hide show
  1. package/README.md +89 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,23 +1,100 @@
1
- # vite-plus-starter
1
+ # rehype-instui-markdown
2
2
 
3
- A starter for creating a Vite Plus project.
3
+ Rehype plugins for use with [instui-markdown](https://www.npmjs.com/package/instui-markdown). They add color swatch markup, icon token markup, and blockquote unwrapping to the rehype pipeline.
4
4
 
5
- ## Development
6
-
7
- - Install dependencies:
5
+ ## Installation
8
6
 
9
7
  ```bash
10
- vp install
8
+ npm install rehype-instui-markdown
11
9
  ```
12
10
 
13
- - Run the unit tests:
11
+ ## Plugins
14
12
 
15
- ```bash
16
- vp test
13
+ ### `rehypeColorCodes`
14
+
15
+ Wraps color literals in `<span class="color-code" data-color="…">` elements so a downstream renderer can display a visual swatch. Supports `#hex` (3, 4, 6, and 8 digit), `rgb()`, `rgba()`, `hsl()`, and `hsla()` formats. Skips any content inside `<pre>` or `<code>` blocks.
16
+
17
+ ```ts
18
+ import { rehypeColorCodes } from "rehype-instui-markdown";
17
19
  ```
18
20
 
19
- - Build the library:
21
+ Input:
20
22
 
21
- ```bash
22
- vp pack
23
+ ```markdown
24
+ The background is #1f2937 and the border is rgba(14, 165, 233, 0.6).
25
+ ```
26
+
27
+ Output (simplified):
28
+
29
+ ```html
30
+ The background is <span class="color-code" data-color="#1f2937">#1f2937</span> and the border is
31
+ <span class="color-code" data-color="rgba(14, 165, 233, 0.6)">rgba(14, 165, 233, 0.6)</span>.
32
+ ```
33
+
34
+ ---
35
+
36
+ ### `rehypeInstUIIconTokens`
37
+
38
+ Wraps `:iconName:` and `:iconName|color:` tokens in `<span class="icon-token" data-icon="…">` elements so a downstream renderer can swap them for icons. Skips any content inside `<pre>` or `<code>` blocks.
39
+
40
+ This plugin is provider-agnostic: it does not decide whether a token maps to InstUI, SimpleIcons, or another icon source. Provider selection and fallback behavior are handled by the consuming renderer.
41
+
42
+ ```ts
43
+ import { rehypeInstUIIconTokens } from "rehype-instui-markdown";
44
+ ```
45
+
46
+ Token syntax:
47
+
48
+ ```
49
+ :IconName:
50
+ :IconName|#hexcolor:
51
+ ```
52
+
53
+ Input:
54
+
55
+ ```markdown
56
+ Save your work :IconSaveLine: or discard :IconTrashLine|#E00:.
57
+ ```
58
+
59
+ Output (simplified):
60
+
61
+ ```html
62
+ Save your work <span class="icon-token" data-icon="IconSaveLine">:IconSaveLine:</span> or discard
63
+ <span class="icon-token" data-icon="IconTrashLine" data-icon-color="#E00">:IconTrashLine|#E00:</span
64
+ >.
65
+ ```
66
+
67
+ ---
68
+
69
+ ### `rehypeUnwrapBlockquoteParagraphs`
70
+
71
+ Unwraps bare `<p>` elements inside `<blockquote>` nodes, hoisting their children directly into the blockquote. This prevents invalid nesting when a downstream component maps blockquotes to elements that expect inline children.
72
+
73
+ ```ts
74
+ import { rehypeUnwrapBlockquoteParagraphs } from "rehype-instui-markdown";
75
+ ```
76
+
77
+ ## Using the plugins directly
78
+
79
+ All three plugins work with any rehype-compatible pipeline.
80
+
81
+ ```ts
82
+ import { unified } from "unified";
83
+ import remarkParse from "remark-parse";
84
+ import remarkRehype from "remark-rehype";
85
+ import rehypeStringify from "rehype-stringify";
86
+ import {
87
+ rehypeColorCodes,
88
+ rehypeInstUIIconTokens,
89
+ rehypeUnwrapBlockquoteParagraphs,
90
+ } from "rehype-instui-markdown";
91
+
92
+ const file = await unified()
93
+ .use(remarkParse)
94
+ .use(remarkRehype)
95
+ .use(rehypeUnwrapBlockquoteParagraphs)
96
+ .use(rehypeInstUIIconTokens)
97
+ .use(rehypeColorCodes)
98
+ .use(rehypeStringify)
99
+ .process(markdownString);
23
100
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rehype-instui-markdown",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Rehype plugins for InstUI markdown rendering",
5
5
  "license": "MIT",
6
6
  "files": [