|
| 1 | +// TypeScript Version: 3.5 |
| 2 | +import {Node} from 'unist' |
| 3 | +import {Document} from 'parse5' |
| 4 | +import {VFile} from 'vfile' |
| 5 | + |
| 6 | +declare namespace hastUtilFromParse5 { |
| 7 | + interface HastUtilFromParse5Options { |
| 8 | + /** |
| 9 | + * Whether the [*root*](https://github.com/syntax-tree/unist#root) of the |
| 10 | + * [*tree*](https://github.com/syntax-tree/unist#tree) is in the `'html'` or `'svg'` |
| 11 | + * space. |
| 12 | + * |
| 13 | + * If an element in with the SVG namespace is found in `ast`, `fromParse5` |
| 14 | + * automatically switches to the SVG space when entering the element, and switches |
| 15 | + * back when leaving. |
| 16 | + * |
| 17 | + * @default 'html' |
| 18 | + */ |
| 19 | + space?: 'html' | 'svg' |
| 20 | + |
| 21 | + /** |
| 22 | + * [`VFile`](https://github.com/vfile/vfile), used to add |
| 23 | + * [positional information](https://github.com/syntax-tree/unist#positional-information) |
| 24 | + * to [*nodes*](https://github.com/syntax-tree/hast#nodes). |
| 25 | + * If given, the [*file*](https://github.com/syntax-tree/unist#file) should have the |
| 26 | + * original HTML source as its contents. |
| 27 | + */ |
| 28 | + file?: VFile |
| 29 | + /** |
| 30 | + * |
| 31 | + * Whether to add extra positional information about starting tags, closing tags, |
| 32 | + * and attributes to elements. |
| 33 | + * |
| 34 | + * Note: not used without `file`. |
| 35 | + * |
| 36 | + * @default: false |
| 37 | + */ |
| 38 | + verbose?: boolean |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +/** |
| 43 | + * Transform [Parse5’s AST](https://github.com/inikulin/parse5/blob/master/packages/parse5/docs/tree-adapter/default/interface-list.md) |
| 44 | + * to a [**hast**](https://github.com/syntax-tree/hast) |
| 45 | + * [*tree*](https://github.com/syntax-tree/unist#tree). |
| 46 | + * |
| 47 | + * @param options If `options` is a [`VFile`](https://github.com/vfile/vfile), it’s treated |
| 48 | + * as `{file: options}`. |
| 49 | + */ |
| 50 | +declare function hastUtilFromParse5( |
| 51 | + ast: Document, |
| 52 | + options?: hastUtilFromParse5.HastUtilFromParse5Options | VFile |
| 53 | +): Node |
| 54 | + |
| 55 | +export = hastUtilFromParse5 |
0 commit comments