Skip to content

Commit f401100

Browse files
committedNov 19, 2024
Refactor types
1 parent 19e59f5 commit f401100

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed
 

Diff for: ‎index.d.ts

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,42 @@
11
import type {Position} from 'unist'
2-
3-
export type {Options, Space} from './lib/index.js'
2+
import type {VFile} from 'vfile'
43

54
export {fromParse5} from './lib/index.js'
65

6+
/**
7+
* Configuration.
8+
*/
9+
export interface Options {
10+
/**
11+
* File used to add positional info to nodes (optional).
12+
*
13+
* If given, the file should represent the original HTML source.
14+
*/
15+
file?: VFile | null | undefined
16+
17+
/**
18+
* Which space the document is in (default: `'html'`).
19+
*
20+
* When an `<svg>` element is found in the HTML space, this package already
21+
* automatically switches to and from the SVG space when entering and exiting
22+
* it.
23+
*/
24+
space?: Space | null | undefined
25+
26+
/**
27+
* Whether to add extra positional info about starting tags, closing tags,
28+
* and attributes to elements (default: `false`).
29+
*
30+
* > 👉 **Note**: only used when `file` is given.
31+
*/
32+
verbose?: boolean | null | undefined
33+
}
34+
35+
/**
36+
* Namespace.
37+
*/
38+
export type Space = 'html' | 'svg'
39+
740
// Register data on hast.
841
declare module 'hast' {
942
interface ElementData {

Diff for: ‎lib/index.js

+1-21
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,10 @@
44
* @import {Schema} from 'property-information'
55
* @import {Point, Position} from 'unist'
66
* @import {VFile} from 'vfile'
7+
* @import {Options} from 'hast-util-from-parse5'
78
*/
89

910
/**
10-
* @typedef Options
11-
* Configuration.
12-
* @property {Space | null | undefined} [space='html']
13-
* Which space the document is in (default: `'html'`).
14-
*
15-
* When an `<svg>` element is found in the HTML space, this package already
16-
* automatically switches to and from the SVG space when entering and exiting
17-
* it.
18-
* @property {VFile | null | undefined} [file]
19-
* File used to add positional info to nodes (optional).
20-
*
21-
* If given, the file should represent the original HTML source.
22-
* @property {boolean | null | undefined} [verbose=false]
23-
* Whether to add extra positional info about starting tags, closing tags,
24-
* and attributes to elements (default: `false`).
25-
*
26-
* > 👉 **Note**: only used when `file` is given.
27-
*
28-
* @typedef {'html' | 'svg'} Space
29-
* Namespace.
30-
*
3111
* @typedef State
3212
* Info passed around about the current state.
3313
* @property {VFile | undefined} file

0 commit comments

Comments
 (0)