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.

86 lines (85 loc) 2.84 kB
import C from "../token.mjs"; import { isSpace as k } from "../common/utils.mjs"; function o(n, t, s, i) { this.src = n, this.md = t, this.env = s, this.tokens = i, this.bMarks = [], this.eMarks = [], this.tShift = [], this.sCount = [], this.bsCount = [], this.blkIndent = 0, this.line = 0, this.lineMax = 0, this.tight = !1, this.ddIndent = -1, this.listIndent = -1, this.parentType = "root", this.level = 0; const c = this.src; for (let u = 0, r = 0, h = 0, e = 0, f = c.length, a = !1; r < f; r++) { const l = c.charCodeAt(r); if (!a) if (k(l)) { h++, l === 9 ? e += 4 - e % 4 : e++; continue; } else a = !0; (l === 10 || r === f - 1) && (l !== 10 && r++, this.bMarks.push(u), this.eMarks.push(r), this.tShift.push(h), this.sCount.push(e), this.bsCount.push(0), a = !1, h = 0, e = 0, u = r + 1); } this.bMarks.push(c.length), this.eMarks.push(c.length), this.tShift.push(0), this.sCount.push(0), this.bsCount.push(0), this.lineMax = this.bMarks.length - 1; } o.prototype.push = function(n, t, s) { const i = new C(n, t, s); return i.block = !0, s < 0 && this.level--, i.level = this.level, s > 0 && this.level++, this.tokens.push(i), i; }; o.prototype.isEmpty = function(t) { return this.bMarks[t] + this.tShift[t] >= this.eMarks[t]; }; o.prototype.skipEmptyLines = function(t) { for (let s = this.lineMax; t < s && !(this.bMarks[t] + this.tShift[t] < this.eMarks[t]); t++) ; return t; }; o.prototype.skipSpaces = function(t) { for (let s = this.src.length; t < s; t++) { const i = this.src.charCodeAt(t); if (!k(i)) break; } return t; }; o.prototype.skipSpacesBack = function(t, s) { if (t <= s) return t; for (; t > s; ) if (!k(this.src.charCodeAt(--t))) return t + 1; return t; }; o.prototype.skipChars = function(t, s) { for (let i = this.src.length; t < i && this.src.charCodeAt(t) === s; t++) ; return t; }; o.prototype.skipCharsBack = function(t, s, i) { if (t <= i) return t; for (; t > i; ) if (s !== this.src.charCodeAt(--t)) return t + 1; return t; }; o.prototype.getLines = function(t, s, i, c) { if (t >= s) return ""; const u = new Array(s - t); for (let r = 0, h = t; h < s; h++, r++) { let e = 0; const f = this.bMarks[h]; let a = f, l; for (h + 1 < s || c ? l = this.eMarks[h] + 1 : l = this.eMarks[h]; a < l && e < i; ) { const p = this.src.charCodeAt(a); if (k(p)) p === 9 ? e += 4 - (e + this.bsCount[h]) % 4 : e++; else if (a - f < this.tShift[h]) e++; else break; a++; } e > i ? u[r] = new Array(e - i + 1).join(" ") + this.src.slice(a, l) : u[r] = this.src.slice(a, l); } return u.join(""); }; o.prototype.Token = C; export { o as default }; //# sourceMappingURL=state_block.mjs.map