UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

50 lines (49 loc) 1.8 kB
import { isSpace as u, normalizeReference as C } from "../common/utils.mjs"; function v(r, b) { let o, h, p, e, d, n, c, f, s = ""; const x = r.pos, i = r.posMax; if (r.src.charCodeAt(r.pos) !== 33 || r.src.charCodeAt(r.pos + 1) !== 91) return !1; const k = r.pos + 2, l = r.md.helpers.parseLinkLabel(r, r.pos + 1, !1); if (l < 0) return !1; if (e = l + 1, e < i && r.src.charCodeAt(e) === 40) { for (e++; e < i && (o = r.src.charCodeAt(e), !(!u(o) && o !== 10)); e++) ; if (e >= i) return !1; for (f = e, n = r.md.helpers.parseLinkDestination(r.src, e, r.posMax), n.ok && (s = r.md.normalizeLink(n.str), r.md.validateLink(s) ? e = n.pos : s = ""), f = e; e < i && (o = r.src.charCodeAt(e), !(!u(o) && o !== 10)); e++) ; if (n = r.md.helpers.parseLinkTitle(r.src, e, r.posMax), e < i && f !== e && n.ok) for (c = n.str, e = n.pos; e < i && (o = r.src.charCodeAt(e), !(!u(o) && o !== 10)); e++) ; else c = ""; if (e >= i || r.src.charCodeAt(e) !== 41) return r.pos = x, !1; e++; } else { if (typeof r.env.references > "u") return !1; if (e < i && r.src.charCodeAt(e) === 91 ? (f = e + 1, e = r.md.helpers.parseLinkLabel(r, e), e >= 0 ? p = r.src.slice(f, e++) : e = l + 1) : e = l + 1, p || (p = r.src.slice(k, l)), d = r.env.references[C(p)], !d) return r.pos = x, !1; s = d.href, c = d.title; } if (!b) { h = r.src.slice(k, l); const a = []; r.md.inline.parse( h, r.md, r.env, a ); const m = r.push("image", "img", 0), A = [["src", s], ["alt", ""]]; m.attrs = A, m.children = a, m.content = h, c && A.push(["title", c]); } return r.pos = e, r.posMax = i, !0; } export { v as default }; //# sourceMappingURL=image.mjs.map