-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,5 @@ | ||
/// <reference types="remark-parse" /> | ||
/// <reference types="remark-stringify" /> | ||
|
||
/** | ||
* @typedef {import('mdast').Root} Root | ||
* @typedef {import('mdast-util-gfm').Options} MdastOptions | ||
* @typedef {import('micromark-extension-gfm').Options} MicromarkOptions | ||
* @typedef {import('unified').Processor<Root>} Processor | ||
*/ | ||
|
||
/** | ||
* @typedef {MicromarkOptions & MdastOptions} Options | ||
* Configuration. | ||
*/ | ||
|
||
import {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm' | ||
import {gfm} from 'micromark-extension-gfm' | ||
|
||
/** @type {Options} */ | ||
const emptyOptions = {} | ||
|
||
/** | ||
* Add support GFM (autolink literals, footnotes, strikethrough, tables, tasklists). | ||
* | ||
* @param {Options | null | undefined} [options] | ||
* Configuration (optional). | ||
* @returns {undefined} | ||
* Nothing. | ||
* @typedef {import('./lib/index.js').Options} Options | ||
*/ | ||
export default function remarkGfm(options) { | ||
// @ts-expect-error: TS is wrong about `this`. | ||
// eslint-disable-next-line unicorn/no-this-assignment | ||
const self = /** @type {Processor} */ (this) | ||
const settings = options || emptyOptions | ||
const data = self.data() | ||
|
||
const micromarkExtensions = | ||
data.micromarkExtensions || (data.micromarkExtensions = []) | ||
const fromMarkdownExtensions = | ||
data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []) | ||
const toMarkdownExtensions = | ||
data.toMarkdownExtensions || (data.toMarkdownExtensions = []) | ||
|
||
micromarkExtensions.push(gfm(settings)) | ||
fromMarkdownExtensions.push(gfmFromMarkdown()) | ||
toMarkdownExtensions.push(gfmToMarkdown(settings)) | ||
} | ||
export {default} from './lib/index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/// <reference types="remark-parse" /> | ||
/// <reference types="remark-stringify" /> | ||
|
||
/** | ||
* @typedef {import('mdast').Root} Root | ||
* @typedef {import('mdast-util-gfm').Options} MdastOptions | ||
* @typedef {import('micromark-extension-gfm').Options} MicromarkOptions | ||
* @typedef {import('unified').Processor<Root>} Processor | ||
*/ | ||
|
||
/** | ||
* @typedef {MicromarkOptions & MdastOptions} Options | ||
* Configuration. | ||
*/ | ||
|
||
import {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm' | ||
import {gfm} from 'micromark-extension-gfm' | ||
|
||
/** @type {Options} */ | ||
const emptyOptions = {} | ||
|
||
/** | ||
* Add support GFM (autolink literals, footnotes, strikethrough, tables, tasklists). | ||
* | ||
* @param {Options | null | undefined} [options] | ||
* Configuration (optional). | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
export default function remarkGfm(options) { | ||
// @ts-expect-error: TS is wrong about `this`. | ||
// eslint-disable-next-line unicorn/no-this-assignment | ||
const self = /** @type {Processor} */ (this) | ||
const settings = options || emptyOptions | ||
const data = self.data() | ||
|
||
const micromarkExtensions = | ||
data.micromarkExtensions || (data.micromarkExtensions = []) | ||
const fromMarkdownExtensions = | ||
data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []) | ||
const toMarkdownExtensions = | ||
data.toMarkdownExtensions || (data.toMarkdownExtensions = []) | ||
|
||
micromarkExtensions.push(gfm(settings)) | ||
fromMarkdownExtensions.push(gfmFromMarkdown()) | ||
toMarkdownExtensions.push(gfmToMarkdown(settings)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"lib/", | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
|