import remarkGfm from 'remark-gfm' ; import remarkParse from 'remark-parse' ; import remarkSlug from 'remark-slug' ; import { unified , Processor } from 'unified' ; import { removePosition } from 'unist-util-remove-position' ; import { imageParagraphToFigure } from './image-paragrpah-to-figure' ; import { marpCodeBlock } from './marp-code-block' ; let parser ; export const parse = async ( md ) => { parser = parser || unified ( ) . use ( remarkParse ) . use ( remarkGfm ) . use ( remarkSlug ) . use ( imageParagraphToFigure ) . use ( [ marpCodeBlock ] ) ; return removePosition ( await parser . run ( parser . parse ( md ) ) , true ) ; } ;