Skip to content

Commit 0ba3b1b

Browse files
committed
Refactor code-style
* Add more docs to JSDoc * Add support for `null` in input of API types
1 parent 00691e9 commit 0ba3b1b

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

lib/index.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/**
22
* @typedef {import('mdast').Delete} Delete
3+
*
34
* @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext
45
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
56
* @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle
7+
*
68
* @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName
79
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
810
* @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle
@@ -11,16 +13,14 @@
1113
import {containerPhrasing} from 'mdast-util-to-markdown/lib/util/container-phrasing.js'
1214
import {track} from 'mdast-util-to-markdown/lib/util/track.js'
1315

14-
/** @type {FromMarkdownExtension} */
15-
export const gfmStrikethroughFromMarkdown = {
16-
canContainEols: ['delete'],
17-
enter: {strikethrough: enterStrikethrough},
18-
exit: {strikethrough: exitStrikethrough}
19-
}
16+
// To do: next major: expose functions.
17+
// To do: next major: use `state`, state utilities.
2018

2119
/**
2220
* List of constructs that occur in phrasing (paragraphs, headings), but cannot
23-
* contain strikethroughs. So they sort of cancel each other out.
21+
* contain strikethrough.
22+
* So they sort of cancel each other out.
23+
* Note: could use a better name.
2424
*
2525
* Note: keep in sync with: <https://github.com/syntax-tree/mdast-util-to-markdown/blob/8ce8dbf/lib/unsafe.js#L14>
2626
*
@@ -35,7 +35,24 @@ const constructsWithoutStrikethrough = [
3535
'titleApostrophe'
3636
]
3737

38-
/** @type {ToMarkdownExtension} */
38+
handleDelete.peek = peekDelete
39+
40+
/**
41+
* Extension for `mdast-util-from-markdown` to enable GFM strikethrough.
42+
*
43+
* @type {FromMarkdownExtension}
44+
*/
45+
export const gfmStrikethroughFromMarkdown = {
46+
canContainEols: ['delete'],
47+
enter: {strikethrough: enterStrikethrough},
48+
exit: {strikethrough: exitStrikethrough}
49+
}
50+
51+
/**
52+
* Extension for `mdast-util-to-markdown` to enable GFM strikethrough.
53+
*
54+
* @type {ToMarkdownExtension}
55+
*/
3956
export const gfmStrikethroughToMarkdown = {
4057
unsafe: [
4158
{
@@ -47,8 +64,6 @@ export const gfmStrikethroughToMarkdown = {
4764
handlers: {delete: handleDelete}
4865
}
4966

50-
handleDelete.peek = peekDelete
51-
5267
/**
5368
* @this {CompileContext}
5469
* @type {FromMarkdownHandle}

0 commit comments

Comments
 (0)