turnish 1.6.0 → 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],
@@ -510,7 +510,8 @@ function j(t, e, n) {
510
510
  const x = {
511
511
  Element: 1,
512
512
  Text: 3,
513
- CDATASection: 4
513
+ CDATASection: 4,
514
+ Comment: 8
514
515
  };
515
516
  function v(t, e) {
516
517
  return Array(e + 1).join(t);
@@ -527,7 +528,7 @@ function Y(t) {
527
528
  function q(t) {
528
529
  return Y(K(t));
529
530
  }
530
- const ye = [
531
+ const ge = [
531
532
  "ADDRESS",
532
533
  "ARTICLE",
533
534
  "ASIDE",
@@ -579,7 +580,7 @@ const ye = [
579
580
  "UL"
580
581
  ];
581
582
  function B(t) {
582
- return P(t, ye);
583
+ return P(t, ge);
583
584
  }
584
585
  const Q = [
585
586
  "AREA",
@@ -602,7 +603,7 @@ const Q = [
602
603
  function X(t) {
603
604
  return P(t, Q);
604
605
  }
605
- function ke(t) {
606
+ function ye(t) {
606
607
  return Z(t, Q);
607
608
  }
608
609
  const J = [
@@ -648,10 +649,10 @@ const J = [
648
649
  "TH",
649
650
  "TD"
650
651
  ];
651
- function Ee(t) {
652
+ function ke(t) {
652
653
  return P(t, J);
653
654
  }
654
- function Te(t) {
655
+ function Ee(t) {
655
656
  return Z(t, J);
656
657
  }
657
658
  function P(t, e) {
@@ -666,23 +667,23 @@ function ee(t) {
666
667
  return t ? t.replace(/(\n+\s*)+/g, `
667
668
  `) : "";
668
669
  }
669
- function xe(t) {
670
+ function Te(t) {
670
671
  return ee(t).replace(/[\t\r\n]+/g, " ").replace(/ {2,}/g, " ").trim();
671
672
  }
672
673
  function b(t) {
673
674
  return ee(t).replace(/[\t\r\n]+/g, " ");
674
675
  }
675
- function $e(t) {
676
+ function xe(t) {
676
677
  const e = t.parentNode;
677
678
  return e ? e.nodeType === x.Element && e.classList && e.classList.contains("code") && e.nodeName === "TD" && t.nodeName === "PRE" : !1;
678
679
  }
679
- function Ae(t) {
680
+ function $e(t) {
680
681
  if (t.nodeName !== "PRE" || t.nodeType !== x.Element)
681
682
  return !1;
682
683
  const e = t.getAttribute("style");
683
684
  if (!e)
684
685
  return !1;
685
- const n = he.parse("pre {" + e + "}");
686
+ const n = me.parse("pre {" + e + "}");
686
687
  if (!n.stylesheet.rules.length)
687
688
  return !1;
688
689
  const i = n.stylesheet.rules[0];
@@ -691,11 +692,11 @@ function Ae(t) {
691
692
  const r = i.declarations.find((l) => "property" in l ? l.property.toLowerCase() === "font-family" : !1);
692
693
  return !r || "value" in r && !r.value ? !1 : "value" in r && r.value.split(",").map((l) => l.trim().toLowerCase()).indexOf("monospace") >= 0;
693
694
  }
694
- function te(t) {
695
- 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;
696
697
  }
697
- const N = {};
698
- N.paragraph = {
698
+ const k = {};
699
+ k.paragraph = {
699
700
  filter: "p",
700
701
  replacement: function(t) {
701
702
  return `
@@ -705,14 +706,14 @@ N.paragraph = {
705
706
  `;
706
707
  }
707
708
  };
708
- N.lineBreak = {
709
+ k.lineBreak = {
709
710
  filter: "br",
710
711
  replacement: function(t, e, n) {
711
712
  return n.br + `
712
713
  `;
713
714
  }
714
715
  };
715
- N.heading = {
716
+ k.heading = {
716
717
  filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
717
718
  replacement: function(t, e, n) {
718
719
  const i = Number(e.nodeName.charAt(1));
@@ -732,7 +733,7 @@ N.heading = {
732
733
  `;
733
734
  }
734
735
  };
735
- N.blockquote = {
736
+ k.blockquote = {
736
737
  filter: "blockquote",
737
738
  replacement: function(t) {
738
739
  return t = q(t).replace(/^/gm, "> "), `
@@ -742,7 +743,7 @@ N.blockquote = {
742
743
  `;
743
744
  }
744
745
  };
745
- N.list = {
746
+ k.list = {
746
747
  filter: ["ul", "ol"],
747
748
  replacement: function(t, e) {
748
749
  const n = e.parentNode;
@@ -754,7 +755,7 @@ N.list = {
754
755
  `;
755
756
  }
756
757
  };
757
- N.listItem = {
758
+ k.listItem = {
758
759
  filter: "li",
759
760
  replacement: function(t, e, n) {
760
761
  let i = n.bulletListMarker + " ".repeat(n.listMarkerSpaceCount);
@@ -783,7 +784,7 @@ N.listItem = {
783
784
  ` : "");
784
785
  }
785
786
  };
786
- N.indentedCodeBlock = {
787
+ k.indentedCodeBlock = {
787
788
  filter: function(t, e) {
788
789
  return !!(e && e.codeBlockStyle === "indented" && t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE");
789
790
  },
@@ -796,7 +797,7 @@ N.indentedCodeBlock = {
796
797
  `;
797
798
  }
798
799
  };
799
- N.fencedCodeBlock = {
800
+ k.fencedCodeBlock = {
800
801
  filter: function(t, e) {
801
802
  return !!(e && e.codeBlockStyle === "fenced" && t.nodeName === "PRE");
802
803
  },
@@ -817,7 +818,7 @@ N.fencedCodeBlock = {
817
818
  `;
818
819
  }
819
820
  };
820
- N.horizontalRule = {
821
+ k.horizontalRule = {
821
822
  filter: "hr",
822
823
  replacement: function(t, e, n) {
823
824
  return `
@@ -827,12 +828,12 @@ N.horizontalRule = {
827
828
  `;
828
829
  }
829
830
  };
830
- N.inlineLink = {
831
+ k.inlineLink = {
831
832
  filter: function(t, e) {
832
833
  return !!(e?.linkStyle === "inlined" && t.nodeName === "A" && t.getAttribute("href"));
833
834
  },
834
835
  replacement: function(t, e) {
835
- const n = xe(t);
836
+ const n = Te(t);
836
837
  let i = e.getAttribute("href")?.replace(/([()])/g, "\\$1"), r;
837
838
  const s = e.getAttribute("title");
838
839
  return s ? r = ' "' + b(s).replace(/"/g, '\\"') + '"' : r = "", "[" + n + "](" + i + r + ")";
@@ -878,18 +879,18 @@ const D = {
878
879
  `, t.references = [], t.urlReferenceIdMap = /* @__PURE__ */ new Map()), e;
879
880
  }
880
881
  };
881
- N.referenceLink = D;
882
- N.emphasis = {
882
+ k.referenceLink = D;
883
+ k.emphasis = {
883
884
  filter: ["em", "i"],
884
885
  replacement: (t, e, n) => (t = t.trim(), t ? n.emDelimiter + t + n.emDelimiter : "")
885
886
  };
886
- N.strong = {
887
+ k.strong = {
887
888
  filter: ["strong", "b"],
888
889
  replacement: (t, e, n) => (t = t.trim(), t ? n.strongDelimiter + t + n.strongDelimiter : "")
889
890
  };
890
- N.code = {
891
+ k.code = {
891
892
  filter: (t) => {
892
- const e = t.parentNode, n = te(e);
893
+ const e = t.parentNode, n = Ae(e);
893
894
  return t.nodeName === "CODE" && !n;
894
895
  },
895
896
  replacement: (t) => {
@@ -900,7 +901,7 @@ N.code = {
900
901
  return i + n + e + n + i;
901
902
  }
902
903
  };
903
- N.image = {
904
+ k.image = {
904
905
  filter: "img",
905
906
  replacement: function(t, e) {
906
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 + '"' : "";
@@ -1130,7 +1131,7 @@ const Ie = [
1130
1131
  [/^>/g, "\\>"],
1131
1132
  [/^(\d+)\. /g, "$1\\. "]
1132
1133
  ], Be = {
1133
- rules: N,
1134
+ rules: k,
1134
1135
  headingStyle: "atx",
1135
1136
  hr: "---",
1136
1137
  bulletListMarker: "-",
@@ -1275,7 +1276,7 @@ class Ve {
1275
1276
  */
1276
1277
  process(e) {
1277
1278
  return Array.from(e.childNodes).reduce((n, i) => {
1278
- const r = fe(i, this.options);
1279
+ const r = he(i, this.options);
1279
1280
  let s = "";
1280
1281
  if (r.nodeType === x.Text) {
1281
1282
  let l = r.nodeValue ?? "";
@@ -1313,9 +1314,6 @@ class Ve {
1313
1314
  const r = e.flankingWhitespace;
1314
1315
  return (r.leading || r.trailing) && (i = i.trim()), r.leading + n.replacement(i, e, this.options) + r.trailing;
1315
1316
  }
1316
- isCodeBlock(e) {
1317
- return te(e);
1318
- }
1319
1317
  }
1320
1318
  function G(t, e) {
1321
1319
  const n = Y(t), i = K(e), r = Math.max(t.length - n.length, e.length - i.length), s = `
@@ -1327,6 +1325,9 @@ function Pe(t) {
1327
1325
  return t != null && (typeof t == "string" || t.nodeType && (t.nodeType === 1 || t.nodeType === 9 || t.nodeType === 11));
1328
1326
  }
1329
1327
  export {
1330
- Ve as default
1328
+ x as NodeTypes,
1329
+ Re as Rules,
1330
+ Ve as default,
1331
+ Ae as isCodeBlock
1331
1332
  };
1332
1333
  //# sourceMappingURL=index.mjs.map