Skip to content

Commit 246c313

Browse files
committed
Remove Raw type
Get it from `mdast-util-to-hast`.
1 parent ae7296e commit 246c313

File tree

5 files changed

+14
-43
lines changed

5 files changed

+14
-43
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ coverage/
22
node_modules/
33
.DS_Store
44
*.log
5-
lib/**/*.d.ts
6-
test.d.ts
5+
*.d.ts
6+
!/test-types.d.ts
77
yarn.lock

index.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
// Note: see `index.d.ts` for exposed types.
1+
/**
2+
* @typedef {import('./lib/index.js').Options} Options
3+
*/
4+
25
export {raw} from './lib/index.js'

readme.md

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ HTML) again, keeping positional info okay.
2020
* [API](#api)
2121
* [`raw(tree[, options])`](#rawtree-options)
2222
* [`Options`](#options)
23-
* [`Raw`](#raw)
2423
* [Types](#types)
2524
* [Compatibility](#compatibility)
2625
* [Security](#security)
@@ -39,7 +38,7 @@ it, while keeping the original data and positional info intact.
3938

4039
This utility is particularly useful when coming from markdown and wanting to
4140
support HTML embedded inside that markdown (which requires passing
42-
`allowDangerousHtml: true` to `mdast-util-to-hast`).
41+
`allowDangerousHtml: true` to [`mdast-util-to-hast`][mdast-util-to-hast]).
4342
Markdown dictates how, say, a list item or emphasis can be parsed.
4443
We can use that to turn the markdown syntax tree into an HTML syntax tree.
4544
But markdown also dictates that things that look like HTML, are passed through
@@ -150,41 +149,13 @@ Configuration (TypeScript type).
150149
* `file` ([`VFile`][vfile], optional)
151150
— corresponding virtual file representing the input document
152151

153-
### `Raw`
154-
155-
Interface of semistandard `Raw` nodes (TypeScript type).
156-
157-
###### Type
158-
159-
```ts
160-
export interface Raw extends Literal {
161-
type: 'raw'
162-
}
163-
```
164-
165152
## Types
166153

167154
This package is fully typed with [TypeScript][].
168-
It exports the additional types [`Options`][options] and [`Raw`][raw-node].
169-
170-
The types also register the `Raw` node type with `@types/hast`.
171-
If you’re working with the syntax tree, make sure to import this utility
172-
somewhere in your types, as that registers the new node types in the tree.
155+
It exports the additional type [`Options`][options].
173156

174-
```js
175-
/**
176-
* @typedef {import('hast-util-raw')}
177-
*/
178-
179-
import {visit} from 'unist-util-visit'
180-
181-
/** @type {import('hast').Root} */
182-
const tree = getHastNodeSomeHow()
183-
184-
visit(tree, function (node) {
185-
// `node` can now be a `raw` node.
186-
})
187-
```
157+
The `Raw` node type is registered by and exposed from
158+
[`mdast-util-to-hast`][mdast-util-to-hast].
188159

189160
## Compatibility
190161

@@ -215,7 +186,7 @@ Either do not use this utility in combination with user input, or use
215186

216187
## Related
217188

218-
* [`mdast-util-to-hast`](https://github.com/syntax-tree/mdast-util-to-hast)
189+
* [`mdast-util-to-hast`][mdast-util-to-hast]
219190
— transform mdast to hast
220191
* [`rehype-raw`](https://github.com/rehypejs/rehype-raw)
221192
— rehype plugin
@@ -288,6 +259,8 @@ abide by its terms.
288259

289260
[node]: https://github.com/syntax-tree/hast#nodes
290261

262+
[mdast-util-to-hast]: https://github.com/syntax-tree/mdast-util-to-hast
263+
291264
[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
292265

293266
[vfile]: https://github.com/vfile/vfile
@@ -299,5 +272,3 @@ abide by its terms.
299272
[raw]: #rawtree-options
300273

301274
[options]: #options
302-
303-
[raw-node]: #raw

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"target": "es2020"
1212
},
1313
"exclude": ["coverage/", "node_modules/"],
14-
"include": ["**/**.js", "index.d.ts"]
14+
"include": ["**/**.js", "test-types.d.ts"]
1515
}

0 commit comments

Comments
 (0)