turnish 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- class ae extends Error {
1
+ class oe extends Error {
2
2
  reason;
3
3
  filename;
4
4
  line;
@@ -8,7 +8,7 @@ class ae extends Error {
8
8
  super(`${e}:${i}:${r}: ${n}`), this.reason = n, this.filename = e, this.line = i, this.column = r, this.source = s;
9
9
  }
10
10
  }
11
- class ce {
11
+ class ae {
12
12
  start;
13
13
  end;
14
14
  source;
@@ -85,7 +85,7 @@ function L(t, e) {
85
85
  }
86
86
  return n && Object.defineProperty(t, "parent", { configurable: !0, writable: !0, enumerable: !1, value: e || null }), t;
87
87
  }
88
- class le {
88
+ class ce {
89
89
  level = 0;
90
90
  indentation = " ";
91
91
  compress = !1;
@@ -266,16 +266,16 @@ ${this.indent()}}`);
266
266
  `.padEnd(22) + this.indent()), e.position) + this.emit(";") : this.emit(this.indent()) + this.emit(`${e.property}: ${e.value}`, e.position) + this.emit(";");
267
267
  }
268
268
  }
269
- const ue = (t, e) => {
269
+ const le = (t, e) => {
270
270
  e = e || {};
271
271
  let n = 1, i = 1;
272
272
  function r() {
273
273
  const a = { line: n, column: i };
274
- return (o) => (o.position = new ce(a, { line: n, column: i }, e?.source || ""), E(), o);
274
+ return (o) => (o.position = new ae(a, { line: n, column: i }, e?.source || ""), E(), o);
275
275
  }
276
276
  const s = [];
277
277
  function l(a) {
278
- const o = new ae(e?.source || "", a, n, i, t);
278
+ const o = new oe(e?.source || "", a, n, i, t);
279
279
  if (!e?.silent) throw o;
280
280
  s.push(o);
281
281
  }
@@ -290,7 +290,7 @@ const ue = (t, e) => {
290
290
  function g() {
291
291
  let a;
292
292
  const o = [];
293
- for (E(), d(o); t.length && t.charAt(0) !== "}" && (a = se() || oe(), a); ) o.push(a), d(o);
293
+ for (E(), d(o); t.length && t.charAt(0) !== "}" && (a = re() || se(), a); ) o.push(a), d(o);
294
294
  return o;
295
295
  }
296
296
  function m(a) {
@@ -326,9 +326,9 @@ const ue = (t, e) => {
326
326
  const p = [];
327
327
  let y = 0;
328
328
  for (; y < o.length; ) {
329
- const k = M(o, h, y);
330
- if (k === -1) return p.push(o.substring(y)), p;
331
- p.push(o.substring(y, k)), y = k + 1;
329
+ const N = M(o, h, y);
330
+ if (N === -1) return p.push(o.substring(y)), p;
331
+ p.push(o.substring(y, N)), y = N + 1;
332
332
  }
333
333
  return p;
334
334
  })(T(a[0]).replace(w, ""), [","]).map((o) => T(o));
@@ -341,8 +341,8 @@ const ue = (t, e) => {
341
341
  if (!p) return l("property missing ':'");
342
342
  m(p);
343
343
  let y = "";
344
- const k = M(t, [";", "}"]);
345
- k !== -1 && (y = t.substring(0, k), m([y]), y = T(y).replace(w, ""));
344
+ const N = M(t, [";", "}"]);
345
+ N !== -1 && (y = t.substring(0, N), m([y]), y = T(y).replace(w, ""));
346
346
  const R = a({ type: f.declaration, property: h.replace(w, ""), value: y }), _ = /^[;\s]*/.exec(t);
347
347
  return _ && m(_), R;
348
348
  }
@@ -365,17 +365,17 @@ const ue = (t, e) => {
365
365
  }
366
366
  if (a.length) return o({ type: f.keyframe, values: a, declarations: H() || [] });
367
367
  }
368
- const ne = C("import"), ie = C("charset"), re = C("namespace");
368
+ const te = C("import"), ne = C("charset"), ie = C("namespace");
369
369
  function C(a) {
370
370
  const o = new RegExp("^@" + a + `\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);
371
371
  return () => {
372
372
  const h = r(), p = o.exec(t);
373
373
  if (!p) return;
374
- const y = m(p), k = { type: a };
375
- return k[a] = y[1].trim(), h(k);
374
+ const y = m(p), N = { type: a };
375
+ return N[a] = y[1].trim(), h(N);
376
376
  };
377
377
  }
378
- function se() {
378
+ function re() {
379
379
  if (t[0] === "@") return (function() {
380
380
  const a = r(), o = /^@([-\w]+)?keyframes\s*/.exec(t);
381
381
  if (!o) return;
@@ -383,9 +383,9 @@ const ue = (t, e) => {
383
383
  if (!p) return l("@keyframes missing name");
384
384
  const y = m(p)[1];
385
385
  if (!u()) return l("@keyframes missing '{'");
386
- let k = d(), R = F();
387
- for (; R; ) k.push(R), k = k.concat(d()), R = F();
388
- return c() ? a({ type: f.keyframes, name: y, vendor: h, keyframes: k }) : l("@keyframes missing '}'");
386
+ let N = d(), R = F();
387
+ for (; R; ) N.push(R), N = N.concat(d()), R = F();
388
+ return c() ? a({ type: f.keyframes, name: y, vendor: h, keyframes: N }) : l("@keyframes missing '}'");
389
389
  })() || (function() {
390
390
  const a = r(), o = /^@media *([^{]+)/.exec(t);
391
391
  if (!o) return;
@@ -405,13 +405,13 @@ const ue = (t, e) => {
405
405
  if (!u()) return l("@supports missing '{'");
406
406
  const p = d().concat(g());
407
407
  return c() ? a({ type: f.supports, supports: h, rules: p }) : l("@supports missing '}'");
408
- })() || ne() || ie() || re() || (function() {
408
+ })() || te() || ne() || ie() || (function() {
409
409
  const a = r(), o = /^@([-\w]+)?document *([^{]+)/.exec(t);
410
410
  if (!o) return;
411
411
  const h = m(o), p = T(h[1]), y = T(h[2]);
412
412
  if (!u()) return l("@document missing '{'");
413
- const k = d().concat(g());
414
- return c() ? a({ type: f.document, document: y, vendor: p, rules: k }) : l("@document missing '}'");
413
+ const N = d().concat(g());
414
+ return c() ? a({ type: f.document, document: y, vendor: p, rules: N }) : l("@document missing '}'");
415
415
  })() || (function() {
416
416
  const a = r(), o = /^@page */.exec(t);
417
417
  if (!o) return;
@@ -459,7 +459,7 @@ const ue = (t, e) => {
459
459
  return c() ? a({ type: f.layer, layer: h, rules: p }) : l("@layer missing '}'");
460
460
  })();
461
461
  }
462
- function oe() {
462
+ function se() {
463
463
  const a = r(), o = V();
464
464
  return o ? (d(), a({ type: f.rule, selectors: o, declarations: H() || [] })) : l("selector missing");
465
465
  }
@@ -467,23 +467,23 @@ const ue = (t, e) => {
467
467
  const a = g();
468
468
  return { type: f.stylesheet, stylesheet: { source: e?.source, rules: a, parsingErrors: s } };
469
469
  })());
470
- }, me = (t, e) => new le(e || {}).compile(t);
471
- var he = { parse: ue, stringify: me };
472
- function fe(t, e) {
470
+ }, ue = (t, e) => new ce(e || {}).compile(t);
471
+ var me = { parse: le, stringify: ue };
472
+ function he(t, e) {
473
473
  const n = t;
474
- return n.isBlock = B(n), n.isCode = n.nodeName === "CODE" || n.parentNode?.isCode, n.isBlank = pe(n), n.flankingWhitespace = de(n, e), n;
474
+ return n.isBlock = B(n), n.isCode = n.nodeName === "CODE" || n.parentNode?.isCode, n.isBlank = fe(n), n.flankingWhitespace = pe(n, e), n;
475
475
  }
476
- function pe(t) {
477
- return !X(t) && !Ee(t) && /^\s*$/i.test(t.textContent || "") && !ke(t) && !Te(t);
476
+ function fe(t) {
477
+ return !X(t) && !ke(t) && /^\s*$/i.test(t.textContent || "") && !ye(t) && !Ee(t);
478
478
  }
479
- function de(t, e) {
479
+ function pe(t, e) {
480
480
  const n = t;
481
481
  if (n.isBlock || e.preformattedCode && n.isCode)
482
482
  return { leading: "", trailing: "" };
483
- const i = ge(t.textContent || "");
483
+ const i = de(t.textContent || "");
484
484
  return i.leadingAscii && j("left", t, e) && (i.leading = i.leadingNonAscii), i.trailingAscii && j("right", t, e) && (i.trailing = i.trailingNonAscii), { leading: i.leading, trailing: i.trailing };
485
485
  }
486
- function ge(t) {
486
+ function de(t) {
487
487
  const e = t.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
488
488
  return e ? {
489
489
  leading: e[1],
@@ -528,7 +528,7 @@ function Y(t) {
528
528
  function q(t) {
529
529
  return Y(K(t));
530
530
  }
531
- const ye = [
531
+ const ge = [
532
532
  "ADDRESS",
533
533
  "ARTICLE",
534
534
  "ASIDE",
@@ -580,7 +580,7 @@ const ye = [
580
580
  "UL"
581
581
  ];
582
582
  function B(t) {
583
- return P(t, ye);
583
+ return P(t, ge);
584
584
  }
585
585
  const Q = [
586
586
  "AREA",
@@ -603,7 +603,7 @@ const Q = [
603
603
  function X(t) {
604
604
  return P(t, Q);
605
605
  }
606
- function ke(t) {
606
+ function ye(t) {
607
607
  return Z(t, Q);
608
608
  }
609
609
  const J = [
@@ -649,10 +649,10 @@ const J = [
649
649
  "TH",
650
650
  "TD"
651
651
  ];
652
- function Ee(t) {
652
+ function ke(t) {
653
653
  return P(t, J);
654
654
  }
655
- function Te(t) {
655
+ function Ee(t) {
656
656
  return Z(t, J);
657
657
  }
658
658
  function P(t, e) {
@@ -667,23 +667,23 @@ function ee(t) {
667
667
  return t ? t.replace(/(\n+\s*)+/g, `
668
668
  `) : "";
669
669
  }
670
- function xe(t) {
670
+ function Te(t) {
671
671
  return ee(t).replace(/[\t\r\n]+/g, " ").replace(/ {2,}/g, " ").trim();
672
672
  }
673
673
  function b(t) {
674
674
  return ee(t).replace(/[\t\r\n]+/g, " ");
675
675
  }
676
- function $e(t) {
676
+ function xe(t) {
677
677
  const e = t.parentNode;
678
678
  return e ? e.nodeType === x.Element && e.classList && e.classList.contains("code") && e.nodeName === "TD" && t.nodeName === "PRE" : !1;
679
679
  }
680
- function Ae(t) {
680
+ function $e(t) {
681
681
  if (t.nodeName !== "PRE" || t.nodeType !== x.Element)
682
682
  return !1;
683
683
  const e = t.getAttribute("style");
684
684
  if (!e)
685
685
  return !1;
686
- const n = he.parse("pre {" + e + "}");
686
+ const n = me.parse("pre {" + e + "}");
687
687
  if (!n.stylesheet.rules.length)
688
688
  return !1;
689
689
  const i = n.stylesheet.rules[0];
@@ -692,11 +692,11 @@ function Ae(t) {
692
692
  const r = i.declarations.find((l) => "property" in l ? l.property.toLowerCase() === "font-family" : !1);
693
693
  return !r || "value" in r && !r.value ? !1 : "value" in r && r.value.split(",").map((l) => l.trim().toLowerCase()).indexOf("monospace") >= 0;
694
694
  }
695
- function te(t) {
696
- return $e(t) || Ae(t) ? !0 : t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE" || !1;
695
+ function Ae(t) {
696
+ return xe(t) || $e(t) ? !0 : t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE" || !1;
697
697
  }
698
- const N = {};
699
- N.paragraph = {
698
+ const k = {};
699
+ k.paragraph = {
700
700
  filter: "p",
701
701
  replacement: function(t) {
702
702
  return `
@@ -706,14 +706,14 @@ N.paragraph = {
706
706
  `;
707
707
  }
708
708
  };
709
- N.lineBreak = {
709
+ k.lineBreak = {
710
710
  filter: "br",
711
711
  replacement: function(t, e, n) {
712
712
  return n.br + `
713
713
  `;
714
714
  }
715
715
  };
716
- N.heading = {
716
+ k.heading = {
717
717
  filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
718
718
  replacement: function(t, e, n) {
719
719
  const i = Number(e.nodeName.charAt(1));
@@ -733,7 +733,7 @@ N.heading = {
733
733
  `;
734
734
  }
735
735
  };
736
- N.blockquote = {
736
+ k.blockquote = {
737
737
  filter: "blockquote",
738
738
  replacement: function(t) {
739
739
  return t = q(t).replace(/^/gm, "> "), `
@@ -743,7 +743,7 @@ N.blockquote = {
743
743
  `;
744
744
  }
745
745
  };
746
- N.list = {
746
+ k.list = {
747
747
  filter: ["ul", "ol"],
748
748
  replacement: function(t, e) {
749
749
  const n = e.parentNode;
@@ -755,7 +755,7 @@ N.list = {
755
755
  `;
756
756
  }
757
757
  };
758
- N.listItem = {
758
+ k.listItem = {
759
759
  filter: "li",
760
760
  replacement: function(t, e, n) {
761
761
  let i = n.bulletListMarker + " ".repeat(n.listMarkerSpaceCount);
@@ -784,7 +784,7 @@ N.listItem = {
784
784
  ` : "");
785
785
  }
786
786
  };
787
- N.indentedCodeBlock = {
787
+ k.indentedCodeBlock = {
788
788
  filter: function(t, e) {
789
789
  return !!(e && e.codeBlockStyle === "indented" && t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE");
790
790
  },
@@ -797,7 +797,7 @@ N.indentedCodeBlock = {
797
797
  `;
798
798
  }
799
799
  };
800
- N.fencedCodeBlock = {
800
+ k.fencedCodeBlock = {
801
801
  filter: function(t, e) {
802
802
  return !!(e && e.codeBlockStyle === "fenced" && t.nodeName === "PRE");
803
803
  },
@@ -818,7 +818,7 @@ N.fencedCodeBlock = {
818
818
  `;
819
819
  }
820
820
  };
821
- N.horizontalRule = {
821
+ k.horizontalRule = {
822
822
  filter: "hr",
823
823
  replacement: function(t, e, n) {
824
824
  return `
@@ -828,12 +828,12 @@ N.horizontalRule = {
828
828
  `;
829
829
  }
830
830
  };
831
- N.inlineLink = {
831
+ k.inlineLink = {
832
832
  filter: function(t, e) {
833
833
  return !!(e?.linkStyle === "inlined" && t.nodeName === "A" && t.getAttribute("href"));
834
834
  },
835
835
  replacement: function(t, e) {
836
- const n = xe(t);
836
+ const n = Te(t);
837
837
  let i = e.getAttribute("href")?.replace(/([()])/g, "\\$1"), r;
838
838
  const s = e.getAttribute("title");
839
839
  return s ? r = ' "' + b(s).replace(/"/g, '\\"') + '"' : r = "", "[" + n + "](" + i + r + ")";
@@ -879,18 +879,18 @@ const D = {
879
879
  `, t.references = [], t.urlReferenceIdMap = /* @__PURE__ */ new Map()), e;
880
880
  }
881
881
  };
882
- N.referenceLink = D;
883
- N.emphasis = {
882
+ k.referenceLink = D;
883
+ k.emphasis = {
884
884
  filter: ["em", "i"],
885
885
  replacement: (t, e, n) => (t = t.trim(), t ? n.emDelimiter + t + n.emDelimiter : "")
886
886
  };
887
- N.strong = {
887
+ k.strong = {
888
888
  filter: ["strong", "b"],
889
889
  replacement: (t, e, n) => (t = t.trim(), t ? n.strongDelimiter + t + n.strongDelimiter : "")
890
890
  };
891
- N.code = {
891
+ k.code = {
892
892
  filter: (t) => {
893
- const e = t.parentNode, n = te(e);
893
+ const e = t.parentNode, n = Ae(e);
894
894
  return t.nodeName === "CODE" && !n;
895
895
  },
896
896
  replacement: (t) => {
@@ -901,7 +901,7 @@ N.code = {
901
901
  return i + n + e + n + i;
902
902
  }
903
903
  };
904
- N.image = {
904
+ k.image = {
905
905
  filter: "img",
906
906
  replacement: function(t, e) {
907
907
  const n = e.getAttribute("alt"), i = n ? b(n) : "", r = e.getAttribute("src") || "", s = e.getAttribute("title"), l = s ? b(s) : "", u = l ? ' "' + l + '"' : "";
@@ -1131,7 +1131,7 @@ const Ie = [
1131
1131
  [/^>/g, "\\>"],
1132
1132
  [/^(\d+)\. /g, "$1\\. "]
1133
1133
  ], Be = {
1134
- rules: N,
1134
+ rules: k,
1135
1135
  headingStyle: "atx",
1136
1136
  hr: "---",
1137
1137
  bulletListMarker: "-",
@@ -1276,7 +1276,7 @@ class Ve {
1276
1276
  */
1277
1277
  process(e) {
1278
1278
  return Array.from(e.childNodes).reduce((n, i) => {
1279
- const r = fe(i, this.options);
1279
+ const r = he(i, this.options);
1280
1280
  let s = "";
1281
1281
  if (r.nodeType === x.Text) {
1282
1282
  let l = r.nodeValue ?? "";
@@ -1314,16 +1314,6 @@ class Ve {
1314
1314
  const r = e.flankingWhitespace;
1315
1315
  return (r.leading || r.trailing) && (i = i.trim()), r.leading + n.replacement(i, e, this.options) + r.trailing;
1316
1316
  }
1317
- /**
1318
- * Determines whether a node is a code block
1319
- * @public
1320
- * @param {Node} node The node to check
1321
- * @returns True if the node is a code block, false otherwise
1322
- * @type boolean
1323
- */
1324
- isCodeBlock(e) {
1325
- return te(e);
1326
- }
1327
1317
  }
1328
1318
  function G(t, e) {
1329
1319
  const n = Y(t), i = K(e), r = Math.max(t.length - n.length, e.length - i.length), s = `
@@ -1337,6 +1327,7 @@ function Pe(t) {
1337
1327
  export {
1338
1328
  x as NodeTypes,
1339
1329
  Re as Rules,
1340
- Ve as default
1330
+ Ve as default,
1331
+ Ae as isCodeBlock
1341
1332
  };
1342
1333
  //# sourceMappingURL=index.mjs.map