2021-07-07 20:10:09 +00:00
|
|
|
import { mdxExpression } from 'micromark-extension-mdx-expression';
|
|
|
|
import { mdxExpressionFromMarkdown, mdxExpressionToMarkdown } from 'mdast-util-mdx-expression';
|
2021-07-01 16:55:22 +00:00
|
|
|
|
|
|
|
function remarkExpressions(this: any, options: any) {
|
2021-07-07 20:10:09 +00:00
|
|
|
let settings = options || {};
|
|
|
|
let data = this.data();
|
2021-07-01 16:55:22 +00:00
|
|
|
|
2021-07-07 20:10:09 +00:00
|
|
|
add('micromarkExtensions', mdxExpression({}));
|
|
|
|
add('fromMarkdownExtensions', mdxExpressionFromMarkdown);
|
|
|
|
add('toMarkdownExtensions', mdxExpressionToMarkdown);
|
2021-07-01 16:55:22 +00:00
|
|
|
|
|
|
|
function add(field: any, value: any) {
|
|
|
|
/* istanbul ignore if - other extensions. */
|
2021-07-07 20:10:09 +00:00
|
|
|
if (data[field]) data[field].push(value);
|
|
|
|
else data[field] = [value];
|
2021-07-01 16:55:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default remarkExpressions;
|