UNPKG

@nuxtjs/mdc

Version:
34 lines (33 loc) 910 B
import { detab } from "detab"; import { parseThematicBlock } from "./utils.js"; export default (state, node) => { const lang = (node.lang || "") + " " + (node.meta || ""); const { language = "text", highlights, filename, meta } = parseThematicBlock(lang); const value = node.value ? detab(node.value + "\n") : ""; let result = { type: "element", tagName: "code", properties: { __ignoreMap: "" }, children: [{ type: "text", value }] }; if (meta) { result.data = { meta }; } state.patch(node, result); result = state.applyData(node, result); const properties = { language: language || "text", filename, highlights, meta, code: value }; if (language) { properties.className = ["language-" + language]; } result = { type: "element", tagName: "pre", properties, children: [result] }; state.patch(node, result); return result; };