vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
30 lines (29 loc) • 1.05 kB
JavaScript
const k = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;
function p(n, t) {
if (!n.md.options.linkify || n.linkLevel > 0) return !1;
const i = n.pos, s = n.posMax;
if (i + 3 > s || n.src.charCodeAt(i) !== 58 || n.src.charCodeAt(i + 1) !== 47 || n.src.charCodeAt(i + 2) !== 47) return !1;
const o = n.pending.match(k);
if (!o) return !1;
const l = o[1], f = n.md.linkify.matchAtStart(n.src.slice(i - l.length));
if (!f) return !1;
let r = f.url;
if (r.length <= l.length) return !1;
r = r.replace(/\*+$/, "");
const c = n.md.normalizeLink(r);
if (!n.md.validateLink(c)) return !1;
if (!t) {
n.pending = n.pending.slice(0, -l.length);
const e = n.push("link_open", "a", 1);
e.attrs = [["href", c]], e.markup = "linkify", e.info = "auto";
const a = n.push("text", "", 0);
a.content = n.md.normalizeLinkText(r);
const u = n.push("link_close", "a", -1);
u.markup = "linkify", u.info = "auto";
}
return n.pos += r.length - l.length, !0;
}
export {
p as default
};
//# sourceMappingURL=linkify.mjs.map