8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** remark** ] [ remark ] plugin remove markdown formatting.
12
- This essentially removes everything but paragraphs and text nodes .
11
+ ** [ remark] [ ] ** plugin to remove markdown formatting.
12
+ This essentially removes everything but paragraphs and text.
13
13
14
14
> This is one of the first remark plugins, before prefixing with ` remark- ` got
15
15
> cool.
16
16
17
- ## Note!
17
+ ## Contents
18
18
19
- This plugin is ready for the new parser in remark
20
- ([ ` remarkjs/remark#536 ` ] ( https://github.com/remarkjs/remark/pull/536 ) ).
21
- No change is needed: it works exactly the same now as it did before!
19
+ * [ What is this?] ( #what-is-this )
20
+ * [ When should I use this?] ( #when-should-i-use-this )
21
+ * [ Install] ( #install )
22
+ * [ Use] ( #use )
23
+ * [ API] ( #api )
24
+ * [ ` unified().use(stripMarkdown[, options]) ` ] ( #unifiedusestripmarkdown-options )
25
+ * [ ` Handler ` ] ( #handler )
26
+ * [ ` Options ` ] ( #options )
27
+ * [ Types] ( #types )
28
+ * [ Compatibility] ( #compatibility )
29
+ * [ Security] ( #security )
30
+ * [ Contribute] ( #contribute )
31
+ * [ License] ( #license )
22
32
23
- ## Install
33
+ ## What is this?
34
+
35
+ This package is a [ unified] [ ] ([ remark] [ ] ) plugin to remove most nodes so as to
36
+ just leave text.
37
+
38
+ ## When should I use this?
24
39
25
- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
26
- Node 16+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
40
+ You can use this if you want to ignore the syntax of markdown.
27
41
28
- [ npm] [ ] :
42
+ ## Install
43
+
44
+ This package is [ ESM only] [ esm ] .
45
+ In Node.js (version 16+), install with [ npm] [ ] :
29
46
30
47
``` sh
31
48
npm install strip-markdown
32
49
```
33
50
51
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
52
+
53
+ ``` js
54
+ import stripMarkdown from ' https://esm.sh/strip-markdown@5'
55
+ ```
56
+
57
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
58
+
59
+ ``` html
60
+ <script type =" module" >
61
+ import stripMarkdown from ' https://esm.sh/strip-markdown@5?bundle'
62
+ </script >
63
+ ```
64
+
34
65
## Use
35
66
36
67
``` js
@@ -53,22 +84,70 @@ Some emphasis, importance, and code.
53
84
## API
54
85
55
86
This package exports no identifiers.
56
- The default export is ` stripMarkdown ` .
87
+ The default export is [ ` stripMarkdown ` ] [ api-strip-markdown ] .
57
88
58
89
### ` unified().use(stripMarkdown[, options]) `
59
90
60
- Plugin to remove markdown formatting.
91
+ Remove markdown formatting.
92
+
93
+ * remove ` code ` , ` html ` , ` horizontalRule ` , ` table ` , ` toml ` , ` yaml ` , and
94
+ their content
95
+ * render everything else as simple paragraphs without formatting
96
+ * uses ` alt ` text for images
97
+
98
+ ###### Parameters
99
+
100
+ * ` option ` ([ ` Options ` ] [ api-options ] , optional)
101
+ — configuration
102
+
103
+ ###### Returns
104
+
105
+ Transform ([ ` Transformer ` ] [ unified-transformer ] ).
106
+
107
+ ### ` Handler `
108
+
109
+ Transform a node (TypeScript type).
110
+
111
+ ###### Parameters
112
+
113
+ * ` node ` ([ ` Node ` ] [ mdast-node ] )
114
+ — node
115
+
116
+ ###### Returns
117
+
118
+ Result (` Array<Node> ` or ` Node ` ).
61
119
62
- * Removes ` html ` ([ * note* ] [ gh-19 ] ), ` code ` , ` horizontalRule ` , ` table ` , ` yaml ` ,
63
- ` toml ` , and their content
64
- * Render everything else as simple paragraphs without formatting
65
- * Uses ` alt ` text for images
120
+ ### ` Options `
121
+
122
+ Configuration (TypeScript type).
123
+
124
+ ###### Fields
125
+
126
+ * ` keep ` (` Array<string> ` , optional)
127
+ — list of node types to leave unchanged
128
+ * ` remove ` (` Array<[string, Handler] | string> ` , optional)
129
+ — list of node types to remove (or replace, with handlers)
130
+
131
+ ## Types
132
+
133
+ This package is fully typed with [ TypeScript] [ ] .
134
+ It exports the additional types [ ` Handler ` ] [ api-handler ] and
135
+ [ ` Options ` ] [ api-options ] .
136
+
137
+ ## Compatibility
138
+
139
+ Projects maintained by the unified collective are compatible with maintained
140
+ versions of Node.js.
141
+
142
+ When we cut a new major release, we drop support for unmaintained versions of
143
+ Node.
144
+ This means we try to keep the current release line, ` strip-markdown@5 ` ,
145
+ compatible with Node.js 12.
66
146
67
147
## Security
68
148
69
- Use of ` strip-markdown ` does not involve [ ** rehype** ] [ rehype ] ([ ** hast** ] [ hast ] )
70
- or user content so there are no openings for [ cross-site scripting (XSS)] [ xss ]
71
- attacks.
149
+ Use of ` strip-markdown ` does not involve ** [ rehype] [ ] ** (** [ hast] [ ] ** ) or user
150
+ content so there are no openings for [ cross-site scripting (XSS)] [ xss ] attacks.
72
151
73
152
## Contribute
74
153
@@ -98,9 +177,9 @@ abide by its terms.
98
177
99
178
[ downloads ] : https://www.npmjs.com/package/strip-markdown
100
179
101
- [ size-badge ] : https://img.shields.io/bundlephobia/minzip /strip-markdown.svg
180
+ [ size-badge ] : https://img.shields.io/bundlejs/size /strip-markdown
102
181
103
- [ size ] : https://bundlephobia .com/result?p =strip-markdown
182
+ [ size ] : https://bundlejs .com/?q =strip-markdown
104
183
105
184
[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
106
185
@@ -114,24 +193,40 @@ abide by its terms.
114
193
115
194
[ npm ] : https://docs.npmjs.com/cli/install
116
195
196
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
197
+
198
+ [ esmsh ] : https://esm.sh
199
+
117
200
[ health ] : https://github.com/remarkjs/.github
118
201
119
- [ contributing ] : https://github.com/remarkjs/.github/blob/HEAD/contributing.md
202
+ [ contributing ] : https://github.com/remarkjs/.github/blob/main/contributing.md
203
+
204
+ [ support ] : https://github.com/remarkjs/.github/blob/main/support.md
120
205
121
- [ support ] : https://github.com/remarkjs/.github/blob/HEAD/support .md
206
+ [ coc ] : https://github.com/remarkjs/.github/blob/main/code-of-conduct .md
122
207
123
- [ coc ] : https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
208
+ [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
124
209
125
210
[ license ] : license
126
211
127
212
[ author ] : https://wooorm.com
128
213
129
- [ remark ] : https://github.com/remarkjs/remark
214
+ [ hast ] : https://github.com/syntax-tree/hast
130
215
131
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
216
+ [ mdast-node ] : https://github.com/syntax-tree/mdast#nodes
132
217
133
218
[ rehype ] : https://github.com/rehypejs/rehype
134
219
135
- [ hast ] : https://github.com/syntax-tree/hast
220
+ [ remark ] : https://github.com/remarkjs/remark
221
+
222
+ [ typescript ] : https://www.typescriptlang.org
223
+
224
+ [ unified ] : https://github.com/unifiedjs/unified
225
+
226
+ [ unified-transformer ] : https://github.com/unifiedjs/unified#transformer
227
+
228
+ [ api-handler ] : #handler
229
+
230
+ [ api-options ] : #options
136
231
137
- [ gh-19 ] : https://github.com/remarkjs/strip-markdown/issues/19
232
+ [ api-strip-markdown ] : #unifiedusestripmarkdown-options
0 commit comments