ant-design-x-vue-next
Version:
Ant Design X for Vue — community continuation aligned with @ant-design/x
37 lines (36 loc) • 1.07 kB
JavaScript
import { S as u } from "../chunks/module-chunk.mjs";
import { escapeHtml as r } from "./escapeHtml.mjs";
const m = "|";
function g(o, t = {}) {
if (!o)
return "";
const s = new u();
s.use({
renderer: {
link({ href: e, title: a, text: n }) {
const c = a ? ` title="${r(a)}"` : "", i = t.openLinksInNewTab ? ' target="_blank" rel="noopener noreferrer"' : "";
return `<a href="${r(e || "")}"${c}${i}>${n}</a>`;
},
code({ text: e, lang: a }) {
const n = (a || "").trim().split(/\s+/)[0] || "", c = n ? ` class="language-${r(n)}"` : "";
return `<pre${n ? ` data-language="${r(n)}"` : ""}><code${c}>${r(e)}</code></pre>
`;
}
}
}), t.escapeRawHtml && s.use({
renderer: {
html({ raw: e, text: a }) {
return r(e || a || "", !0);
}
}
}), t.markedConfig && s.use(t.markedConfig);
let l = s.parse(o, { async: !1 });
if (t.injectTail) {
const e = t.tailContent ?? m;
l = `${l}<span class="xmd-tail">${r(e)}</span>`;
}
return l;
}
export {
g as parseMarkdown
};