Skip to content

Commit 16bf1a7

Browse files
committed
Add docs to types
1 parent 1111d4c commit 16bf1a7

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ export {all} from './all.js'
2323
const block = convert(['heading', 'paragraph', 'root'])
2424

2525
/**
26+
* Transform hast to mdast.
27+
*
2628
* @param {Node} tree
29+
* Tree (hast).
2730
* @param {Options} [options]
31+
* Configuration (optional).
2832
*/
2933
export function toMdast(tree, options = {}) {
3034
/** @type {Record<string, Element>} */

lib/types.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,45 @@
2525
* @typedef {Record<string, unknown>} Properties
2626
*
2727
* @typedef Options
28-
* @property {Record<string, Handle>} [handlers]
29-
* @property {boolean} [document]
28+
* Configuration (optional).
3029
* @property {boolean} [newlines=false]
30+
* Keep line endings when collapsing whitespace.
31+
* The default collapses to a single space.
3132
* @property {string} [checked='[x]']
33+
* Value to use for a checked checkbox or radio input.
3234
* @property {string} [unchecked='[ ]']
35+
* Value to use for an unchecked checkbox or radio input.
3336
* @property {Array<string>} [quotes=['"']]
37+
* List of quotes to use.
38+
* Each value can be one or two characters.
39+
* When two, the first character determines the opening quote and the second
40+
* the closing quote at that level.
41+
* When one, both the opening and closing quote are that character.
42+
* The order in which the preferred quotes appear determines which quotes to
43+
* use at which level of nesting.
44+
* So, to prefer `‘’` at the first level of nesting, and `“”` at the second,
45+
* pass `['‘’', '“”']`.
46+
* If `<q>`s are nested deeper than the given amount of quotes, the markers
47+
* wrap around: a third level of nesting when using `['«»', '‹›']` should
48+
* have double guillemets, a fourth single, a fifth double again, etc.
49+
* @property {boolean} [document]
50+
* Whether the given tree represents a complete document.
51+
* Applies when the `tree` is a `root` node.
52+
* When the tree represents a complete document, then things are wrapped in
53+
* paragraphs when needed, and otherwise they’re left as-is.
54+
* The default checks for whether there’s mixed content: some phrasing nodes
55+
* *and* some non-phrasing nodes.
56+
* @property {Record<string, Handle>} [handlers]
57+
* Object mapping tag names or node types to functions handling the
58+
* corresponding nodes.
59+
* See `handlers/` for examples.
60+
*
61+
* In a handler, you have access to `h`, which should be used to create mdast
62+
* nodes from hast nodes.
63+
* On `h`, there are several fields that may be of interest.
64+
* Most interesting of them is `h.wrapText`, which is `true` if the mdast
65+
* content can include newlines, and `false` if not (such as in headings or
66+
* table cells).
3467
*
3568
* @typedef Context
3669
* @property {Record<string, Element>} nodeById

0 commit comments

Comments
 (0)