20 lines
439 B
JavaScript
20 lines
439 B
JavaScript
import { fromMarkdown } from 'mdast-util-from-markdown'
|
|
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
|
import { visit } from 'unist-util-visit'
|
|
import { gfm } from 'micromark-extension-gfm'
|
|
|
|
export function mdHas (md, test) {
|
|
const tree = fromMarkdown(md, {
|
|
extensions: [gfm()],
|
|
mdastExtensions: [gfmFromMarkdown()]
|
|
})
|
|
|
|
let found = false
|
|
visit(tree, test, () => {
|
|
found = true
|
|
return false
|
|
})
|
|
|
|
return found
|
|
}
|