-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
36 lines (31 loc) · 957 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {directive} from 'micromark-extension-directive'
import {directiveFromMarkdown, directiveToMarkdown} from 'mdast-util-directive'
let warningIssued
export default function remarkDirective() {
const data = this.data()
// Old remark.
/* c8 ignore next 14 */
if (
!warningIssued &&
((this.Parser &&
this.Parser.prototype &&
this.Parser.prototype.blockTokenizers) ||
(this.Compiler &&
this.Compiler.prototype &&
this.Compiler.prototype.visitors))
) {
warningIssued = true
console.warn(
'[remark-directive] Warning: please upgrade to remark 13 to use this plugin'
)
}
add('micromarkExtensions', directive())
add('fromMarkdownExtensions', directiveFromMarkdown)
add('toMarkdownExtensions', directiveToMarkdown)
function add(field, value) {
// Other extensions.
/* c8 ignore next */
if (data[field]) data[field].push(value)
else data[field] = [value]
}
}