Skip to content

Commit

Permalink
Change gfmFromMarkdown to be a function that returns an extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 3, 2021
1 parent 108249d commit 64de22e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ import {
} from 'mdast-util-gfm-task-list-item'

/**
* @type {Array.<FromMarkdownExtension>}
* @returns {Array.<FromMarkdownExtension>}
*/
export const gfmFromMarkdown = [
gfmAutolinkLiteralFromMarkdown,
gfmStrikethroughFromMarkdown,
gfmTableFromMarkdown,
gfmTaskListItemFromMarkdown
]
export function gfmFromMarkdown() {
return [
gfmAutolinkLiteralFromMarkdown,
gfmStrikethroughFromMarkdown,
gfmTableFromMarkdown,
gfmTaskListItemFromMarkdown
]
}

/**
* @param {Options} [options]
Expand Down
10 changes: 5 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const doc = fs.readFileSync('example.md')

const tree = fromMarkdown(doc, {
extensions: [gfm()],
mdastExtensions: [gfmFromMarkdown]
mdastExtensions: [gfmFromMarkdown()]
})

console.log(tree)
Expand Down Expand Up @@ -219,17 +219,17 @@ Now, running `node example` yields:

## API

This package exports the following identifier: `gfmFromMarkdown`,
This package exports the following identifiers: `gfmFromMarkdown`,
`gfmToMarkdown`.
There is no default export.

### `gfmFromMarkdown`
### `gfmFromMarkdown()`

### `gfmToMarkdown(options?)`

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

Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('markdown -> mdast', (t) => {

const mdast = fromMarkdown(example.input, {
extensions: [gfm()],
mdastExtensions: [gfmFromMarkdown]
mdastExtensions: [gfmFromMarkdown()]
})

const html = toHtml(
Expand Down

0 comments on commit 64de22e

Please sign in to comment.