rehype-instui-markdown 0.0.7 → 0.0.8

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 +87 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,23 +1,98 @@
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 real icon components. Skips any content inside `<pre>` or `<code>` blocks.
39
+
40
+ ```ts
41
+ import { rehypeInstUIIconTokens } from "rehype-instui-markdown";
42
+ ```
43
+
44
+ Token syntax:
45
+
46
+ ```
47
+ :IconName:
48
+ :IconName|#hexcolor:
49
+ ```
50
+
51
+ Input:
52
+
53
+ ```markdown
54
+ Save your work :IconSaveLine: or discard :IconTrashLine|#E00:.
55
+ ```
56
+
57
+ Output (simplified):
58
+
59
+ ```html
60
+ Save your work <span class="icon-token" data-icon="IconSaveLine">:IconSaveLine:</span> or discard
61
+ <span class="icon-token" data-icon="IconTrashLine" data-icon-color="#E00">:IconTrashLine|#E00:</span
62
+ >.
63
+ ```
64
+
65
+ ---
66
+
67
+ ### `rehypeUnwrapBlockquoteParagraphs`
68
+
69
+ 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.
70
+
71
+ ```ts
72
+ import { rehypeUnwrapBlockquoteParagraphs } from "rehype-instui-markdown";
73
+ ```
74
+
75
+ ## Using the plugins directly
76
+
77
+ All three plugins work with any rehype-compatible pipeline.
78
+
79
+ ```ts
80
+ import { unified } from "unified";
81
+ import remarkParse from "remark-parse";
82
+ import remarkRehype from "remark-rehype";
83
+ import rehypeStringify from "rehype-stringify";
84
+ import {
85
+ rehypeColorCodes,
86
+ rehypeInstUIIconTokens,
87
+ rehypeUnwrapBlockquoteParagraphs,
88
+ } from "rehype-instui-markdown";
89
+
90
+ const file = await unified()
91
+ .use(remarkParse)
92
+ .use(remarkRehype)
93
+ .use(rehypeUnwrapBlockquoteParagraphs)
94
+ .use(rehypeInstUIIconTokens)
95
+ .use(rehypeColorCodes)
96
+ .use(rehypeStringify)
97
+ .process(markdownString);
23
98
  ```
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.8",
4
4
  "description": "Rehype plugins for InstUI markdown rendering",
5
5
  "license": "MIT",
6
6
  "files": [