site/node_modules/mdast-util-gfm/lib/index.js
2024-10-14 08:09:33 +02:00

68 lines
1.9 KiB
JavaScript

/**
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
*/
/**
* @typedef {import('mdast-util-gfm-table').Options} Options
* Configuration.
*/
import {
gfmAutolinkLiteralFromMarkdown,
gfmAutolinkLiteralToMarkdown
} from 'mdast-util-gfm-autolink-literal'
import {
gfmFootnoteFromMarkdown,
gfmFootnoteToMarkdown
} from 'mdast-util-gfm-footnote'
import {
gfmStrikethroughFromMarkdown,
gfmStrikethroughToMarkdown
} from 'mdast-util-gfm-strikethrough'
import {gfmTableFromMarkdown, gfmTableToMarkdown} from 'mdast-util-gfm-table'
import {
gfmTaskListItemFromMarkdown,
gfmTaskListItemToMarkdown
} from 'mdast-util-gfm-task-list-item'
/**
* Create an extension for `mdast-util-from-markdown` to enable GFM (autolink
* literals, footnotes, strikethrough, tables, tasklists).
*
* @returns {Array<FromMarkdownExtension>}
* Extension for `mdast-util-from-markdown` to enable GFM (autolink literals,
* footnotes, strikethrough, tables, tasklists).
*/
export function gfmFromMarkdown() {
return [
gfmAutolinkLiteralFromMarkdown(),
gfmFootnoteFromMarkdown(),
gfmStrikethroughFromMarkdown(),
gfmTableFromMarkdown(),
gfmTaskListItemFromMarkdown()
]
}
/**
* Create an extension for `mdast-util-to-markdown` to enable GFM (autolink
* literals, footnotes, strikethrough, tables, tasklists).
*
* @param {Options | null | undefined} [options]
* Configuration.
* @returns {ToMarkdownExtension}
* Extension for `mdast-util-to-markdown` to enable GFM (autolink literals,
* footnotes, strikethrough, tables, tasklists).
*/
export function gfmToMarkdown(options) {
return {
extensions: [
gfmAutolinkLiteralToMarkdown(),
gfmFootnoteToMarkdown(),
gfmStrikethroughToMarkdown(),
gfmTableToMarkdown(options),
gfmTaskListItemToMarkdown()
]
}
}