astro/packages/markdown-support/src/remark-expressions.ts
2021-07-07 20:10:09 +00:00

19 lines
653 B
TypeScript

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