vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
48 lines (47 loc) • 1.51 kB
JavaScript
const f = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/, k = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;
function s(n, a) {
let u = n.pos;
if (n.src.charCodeAt(u) !== 60)
return !1;
const e = n.pos, c = n.posMax;
for (; ; ) {
if (++u >= c) return !1;
const r = n.src.charCodeAt(u);
if (r === 60) return !1;
if (r === 62) break;
}
const o = n.src.slice(e + 1, u);
if (k.test(o)) {
const r = n.md.normalizeLink(o);
if (!n.md.validateLink(r))
return !1;
if (!a) {
const i = n.push("link_open", "a", 1);
i.attrs = [["href", r]], i.markup = "autolink", i.info = "auto";
const t = n.push("text", "", 0);
t.content = n.md.normalizeLinkText(o);
const l = n.push("link_close", "a", -1);
l.markup = "autolink", l.info = "auto";
}
return n.pos += o.length + 2, !0;
}
if (f.test(o)) {
const r = n.md.normalizeLink("mailto:" + o);
if (!n.md.validateLink(r))
return !1;
if (!a) {
const i = n.push("link_open", "a", 1);
i.attrs = [["href", r]], i.markup = "autolink", i.info = "auto";
const t = n.push("text", "", 0);
t.content = n.md.normalizeLinkText(o);
const l = n.push("link_close", "a", -1);
l.markup = "autolink", l.info = "auto";
}
return n.pos += o.length + 2, !0;
}
return !1;
}
export {
s as default
};
//# sourceMappingURL=autolink.mjs.map