1
1
# hast-util-raw
2
2
3
- [ ![ Build] [ build-badge ]] [ build ]
4
- [ ![ Coverage] [ coverage-badge ]] [ coverage ]
5
- [ ![ Downloads] [ downloads-badge ]] [ downloads ]
6
- [ ![ Size] [ size-badge ]] [ size ]
7
- [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8
- [ ![ Backers] [ backers-badge ]] [ collective ]
9
- [ ![ Chat] [ chat-badge ]] [ chat ]
3
+ [ ![ Build] [ badge-build-image ]] [ badge-build-url ]
4
+ [ ![ Coverage] [ badge-coverage-image ]] [ badge-coverage-url ]
5
+ [ ![ Downloads] [ badge-downloads-image ]] [ badge-downloads-url ]
6
+ [ ![ Size] [ badge-size-image ]] [ badge-size-url ]
10
7
11
- [ hast] [ ] utility to parse the tree and semistandard ` raw ` nodes (strings of
12
- HTML) again, keeping positional info okay.
8
+ [ hast] [ github-hast ] utility to parse the tree and semistandard ` raw ` nodes
9
+ (strings of HTML) again, keeping positional info okay.
13
10
14
11
## Contents
15
12
@@ -31,14 +28,15 @@ HTML) again, keeping positional info okay.
31
28
32
29
This package is a utility to parse a document again.
33
30
It passes each node and embedded raw HTML through an HTML parser
34
- ([ ` parse5 ` ] [ parse5 ] ), to recreate a tree exactly as how a browser would parse
35
- it, while keeping the original data and positional info intact.
31
+ ([ ` parse5 ` ] [ github- parse5] ), to recreate a tree exactly as how a browser would
32
+ parse it, while keeping the original data and positional info intact.
36
33
37
34
## When should I use this?
38
35
39
36
This utility is particularly useful when coming from markdown and wanting to
40
37
support HTML embedded inside that markdown (which requires passing
41
- ` allowDangerousHtml: true ` to [ ` mdast-util-to-hast ` ] [ mdast-util-to-hast ] ).
38
+ ` allowDangerousHtml: true ` to
39
+ [ ` mdast-util-to-hast ` ] [ github-mdast-util-to-hast ] ).
42
40
Markdown dictates how, say, a list item or emphasis can be parsed.
43
41
We can use that to turn the markdown syntax tree into an HTML syntax tree.
44
42
But markdown also dictates that things that look like HTML, are passed through
@@ -58,13 +56,13 @@ But there are two main cases where a proper syntax tree is preferred:
58
56
* other output formats (React, MDX, etc) need actual nodes and can’t handle
59
57
strings of HTML
60
58
61
- The plugin [ ` rehype-raw ` ] [ rehype-raw ] wraps this utility at a higher-level
62
- (easier) abstraction.
59
+ The plugin [ ` rehype-raw ` ] [ github- rehype-raw] wraps this utility at a
60
+ higher-level (easier) abstraction.
63
61
64
62
## Install
65
63
66
- This package is [ ESM only] [ esm ] .
67
- In Node.js (version 16+), install with [ npm] [ ] :
64
+ This package is [ ESM only] [ github-gist- esm] .
65
+ In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
68
66
69
67
``` sh
70
68
npm install hast-util-raw
@@ -172,7 +170,7 @@ This package is fully typed with [TypeScript][].
172
170
It exports the additional type [ ` Options ` ] [ api-options ] .
173
171
174
172
The ` Raw ` node type is registered by and exposed from
175
- [ ` mdast-util-to-hast ` ] [ mdast-util-to-hast ] .
173
+ [ ` mdast-util-to-hast ` ] [ github- mdast-util-to-hast] .
176
174
177
175
## Compatibility
178
176
@@ -186,7 +184,8 @@ compatible with Node.js 16.
186
184
187
185
## Security
188
186
189
- Use of ` hast-util-raw ` can open you up to a [ cross-site scripting (XSS)] [ xss ]
187
+ Use of ` hast-util-raw ` can open you up to a
188
+ [ cross-site scripting (XSS)] [ wikipedia-xss ]
190
189
attack as ` raw ` nodes are unsafe.
191
190
The following example shows how a raw node is used to inject a script that runs
192
191
when loaded in a browser.
@@ -202,87 +201,77 @@ Yields:
202
201
```
203
202
204
203
Either do not use this utility in combination with user input, or use
205
- [ ` hast-util-santize ` ] [ hast-util-sanitize ] .
204
+ [ ` hast-util-santize ` ] [ github- hast-util-sanitize] .
206
205
207
206
## Related
208
207
209
- * [ ` mdast-util-to-hast ` ] [ mdast-util-to-hast ]
208
+ * [ ` mdast-util-to-hast ` ] [ github- mdast-util-to-hast]
210
209
— transform mdast to hast
211
- * [ ` rehype-raw ` ] ( https:// github.com/rehypejs/ rehype-raw)
210
+ * [ ` rehype-raw ` ] [ github- rehype-raw ]
212
211
— rehype plugin
213
212
214
213
## Contribute
215
214
216
- See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
217
- ways to get started.
218
- See [ ` support.md ` ] [ support ] for ways to get help.
215
+ See [ ` contributing.md ` ] [ health- contributing] in [ ` syntax-tree/.github ` ] [ health ]
216
+ for ways to get started.
217
+ See [ ` support.md ` ] [ health- support] for ways to get help.
219
218
220
- This project has a [ code of conduct] [ coc ] .
219
+ This project has a [ code of conduct] [ health- coc] .
221
220
By interacting with this repository, organization, or community you agree to
222
221
abide by its terms.
223
222
224
223
## License
225
224
226
- [ MIT] [ license ] © [ Titus Wormer] [ author ]
225
+ [ MIT] [ file- license] © [ Titus Wormer] [ wooorm ]
227
226
228
227
<!-- Definitions -->
229
228
230
- [ build-badge ] : https://github.com/syntax-tree/hast-util-raw/workflows/main/badge.svg
231
-
232
- [ build ] : https://github.com/syntax-tree/hast-util-raw/actions
233
-
234
- [ coverage-badge ] : https://img.shields.io/codecov/c/github/syntax-tree/hast-util-raw.svg
229
+ [ api-options ] : #options
235
230
236
- [ coverage ] : https://codecov.io/github/ syntax-tree/hast-util-raw
231
+ [ badge-build-image ] : https://github.com/ syntax-tree/hast-util-raw/workflows/main/badge.svg
237
232
238
- [ downloads- badge] : https://img.shields.io/npm/dm/ hast-util-raw.svg
233
+ [ badge-build-url ] : https://github.com/syntax-tree/ hast-util-raw/actions
239
234
240
- [ downloads ] : https://www.npmjs.com/package/ hast-util-raw
235
+ [ badge-coverage-image ] : https://img.shields.io/codecov/c/github/syntax-tree/ hast-util-raw.svg
241
236
242
- [ size- badge] : https://img.shields. io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= hast-util-raw
237
+ [ badge-coverage-url ] : https://codecov. io/github/syntax-tree/ hast-util-raw
243
238
244
- [ size ] : https://bundlejs.com/?q= hast-util-raw
239
+ [ badge-downloads-image ] : https://img.shields.io/npm/dm/ hast-util-raw.svg
245
240
246
- [ sponsors- badge] : https://opencollective. com/unified/sponsors/badge.svg
241
+ [ badge-downloads-url ] : https://www.npmjs. com/package/hast-util-raw
247
242
248
- [ backers- badge] : https://opencollective.com/unified/backers/badge.svg
243
+ [ badge-size-image ] : https://img.shields.io/bundlejs/size/hast-util-raw
249
244
250
- [ collective ] : https://opencollective .com/unified
245
+ [ badge-size-url ] : https://bundlejs .com/?q=hast-util-raw
251
246
252
- [ chat-badge ] : https://img.shields.io/badge/chat-discussions-success.svg
247
+ [ esmsh ] : https://esm.sh
253
248
254
- [ chat ] : https://github.com/syntax-tree/unist/discussions
249
+ [ file-license ] : license
255
250
256
- [ npm ] : https://docs.npmjs .com/cli/install
251
+ [ github-gist-esm ] : https://gist.github .com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
257
252
258
- [ esm ] : https://gist. github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
253
+ [ github-hast ] : https://github.com/syntax-tree/hast
259
254
260
- [ esmsh ] : https://esm.sh
255
+ [ github-hast-util-sanitize ] : https://github.com/syntax-tree/hast-util-sanitize
261
256
262
- [ typescript ] : https://www.typescriptlang.org
257
+ [ github-mdast-util-to-hast ] : https://github.com/syntax-tree/mdast-util-to-hast
263
258
264
- [ license ] : license
259
+ [ github-parse5 ] : https://github.com/inikulin/parse5
265
260
266
- [ author ] : https://wooorm .com
261
+ [ github-rehype-raw ] : https://github .com/rehypejs/rehype-raw
267
262
268
263
[ health ] : https://github.com/syntax-tree/.github
269
264
270
- [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
265
+ [ health-coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct .md
271
266
272
- [ support ] : https://github.com/syntax-tree/.github/blob/main/support .md
267
+ [ health-contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
273
268
274
- [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct .md
269
+ [ health-support ] : https://github.com/syntax-tree/.github/blob/main/support .md
275
270
276
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
271
+ [ npmjs-install ] : https://docs.npmjs.com/cli/install
277
272
278
- [ hast ] : https://github.com/syntax-tree/hast
279
-
280
- [ mdast-util-to-hast ] : https://github.com/syntax-tree/mdast-util-to-hast
281
-
282
- [ hast-util-sanitize ] : https://github.com/syntax-tree/hast-util-sanitize
283
-
284
- [ rehype-raw ] : https://github.com/rehypejs/rehype-raw
273
+ [ typescript ] : https://www.typescriptlang.org
285
274
286
- [ parse5 ] : https://github.com/inikulin/parse5
275
+ [ wikipedia-xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
287
276
288
- [ api-options ] : #options
277
+ [ wooorm ] : https://wooorm.com
0 commit comments