vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
33 lines (32 loc) • 1.32 kB
JavaScript
const c = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/, i = /\((c|tm|r)\)/i, l = /\((c|tm|r)\)/ig, r = {
c: "©",
r: "®",
tm: "™"
};
function p(n, e) {
return r[e.toLowerCase()];
}
function f(n) {
let e = 0;
for (let o = n.length - 1; o >= 0; o--) {
const t = n[o];
t.type === "text" && !e && (t.content = t.content.replace(l, p)), t.type === "link_open" && t.info === "auto" && e--, t.type === "link_close" && t.info === "auto" && e++;
}
}
function a(n) {
let e = 0;
for (let o = n.length - 1; o >= 0; o--) {
const t = n[o];
t.type === "text" && !e && c.test(t.content) && (t.content = t.content.replace(/\+-/g, "±").replace(/\.{2,}/g, "…").replace(/([?!])…/g, "$1..").replace(/([?!]){4,}/g, "$1$1$1").replace(/,{2,}/g, ",").replace(/(^|[^-])---(?=[^-]|$)/mg, "$1—").replace(/(^|\s)--(?=\s|$)/mg, "$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg, "$1–")), t.type === "link_open" && t.info === "auto" && e--, t.type === "link_close" && t.info === "auto" && e++;
}
}
function s(n) {
let e;
if (n.md.options.typographer)
for (e = n.tokens.length - 1; e >= 0; e--)
n.tokens[e].type === "inline" && (i.test(n.tokens[e].content) && f(n.tokens[e].children), c.test(n.tokens[e].content) && a(n.tokens[e].children));
}
export {
s as default
};
//# sourceMappingURL=replacements.mjs.map