Skip to content

Commit 64de22e

Browse files
committed
Change gfmFromMarkdown to be a function that returns an extension
1 parent 108249d commit 64de22e

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ import {
2020
} from 'mdast-util-gfm-task-list-item'
2121

2222
/**
23-
* @type {Array.<FromMarkdownExtension>}
23+
* @returns {Array.<FromMarkdownExtension>}
2424
*/
25-
export const gfmFromMarkdown = [
26-
gfmAutolinkLiteralFromMarkdown,
27-
gfmStrikethroughFromMarkdown,
28-
gfmTableFromMarkdown,
29-
gfmTaskListItemFromMarkdown
30-
]
25+
export function gfmFromMarkdown() {
26+
return [
27+
gfmAutolinkLiteralFromMarkdown,
28+
gfmStrikethroughFromMarkdown,
29+
gfmTableFromMarkdown,
30+
gfmTaskListItemFromMarkdown
31+
]
32+
}
3133

3234
/**
3335
* @param {Options} [options]

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const doc = fs.readFileSync('example.md')
8282

8383
const tree = fromMarkdown(doc, {
8484
extensions: [gfm()],
85-
mdastExtensions: [gfmFromMarkdown]
85+
mdastExtensions: [gfmFromMarkdown()]
8686
})
8787

8888
console.log(tree)
@@ -219,17 +219,17 @@ Now, running `node example` yields:
219219

220220
## API
221221

222-
This package exports the following identifier: `gfmFromMarkdown`,
222+
This package exports the following identifiers: `gfmFromMarkdown`,
223223
`gfmToMarkdown`.
224224
There is no default export.
225225

226-
### `gfmFromMarkdown`
226+
### `gfmFromMarkdown()`
227227

228228
### `gfmToMarkdown(options?)`
229229

230230
Support GFM.
231-
The exports of `fromMarkdown` is an extension for
232-
[`mdast-util-from-markdown`][from-markdown].
231+
The export of `fromMarkdown` is a function that can be called and returns an
232+
extension for [`mdast-util-from-markdown`][from-markdown].
233233
The export of `toMarkdown` is a function that can be called with options and
234234
returns an extension for [`mdast-util-to-markdown`][to-markdown].
235235

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test('markdown -> mdast', (t) => {
2525

2626
const mdast = fromMarkdown(example.input, {
2727
extensions: [gfm()],
28-
mdastExtensions: [gfmFromMarkdown]
28+
mdastExtensions: [gfmFromMarkdown()]
2929
})
3030

3131
const html = toHtml(

0 commit comments

Comments
 (0)