-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
29 lines (22 loc) · 802 Bytes
/
index.ts
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
import type { Processor } from 'unified';
import { callout } from './lib/micromark-syntax.js';
import {
calloutFromMarkdown,
calloutToMarkdown
} from './lib/mdast-util.js';
import { mergeWithDefault } from './lib/config.js';
import type { Config } from "./lib/config.js";
export type { Config } from "./lib/config.js";
export default function remarkCallout (this: Processor, config: Config = {}) {
const data = this.data();
const configFull = mergeWithDefault(config);
add('micromarkExtensions', callout());
add('fromMarkdownExtensions', calloutFromMarkdown(configFull));
add('toMarkdownExtensions', calloutToMarkdown());
function add(field: string, value: unknown) {
const list: any = (
data[field] ? data[field] : (data[field] = [])
)
list.push(value)
}
}