@caseparts-org/caseblocks 0.0.196 → 0.0.197

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.
@@ -1,120 +1,131 @@
1
- const g = /^[a-z][a-z0-9_-]*/, y = /^\s*(?:[a-z][a-z0-9_-]*="(?:[^"\\]|\\.)*"(?:[ \t]+[a-z][a-z0-9_-]*="(?:[^"\\]|\\.)*")*)?\s*$/, x = /([a-z][a-z0-9_-]*)="((?:[^"\\]|\\.)*)"/g, d = /^:::[ \t]*$/, b = /* @__PURE__ */ new Set(["note", "tip", "important", "caution", "warning"]), f = (n) => {
2
- if (n.type !== "paragraph" || !n.children || n.children.length === 0) return null;
3
- let t = "";
4
- for (const e of n.children) {
5
- if (e.type === "text" && typeof e.value == "string") {
6
- t += e.value;
1
+ const y = /^[a-z][a-z0-9_-]*/, v = /^\s*(?:[a-z][a-z0-9_-]*="(?:[^"\\]|\\.)*"(?:[ \t]+[a-z][a-z0-9_-]*="(?:[^"\\]|\\.)*")*)?\s*$/, x = /([a-z][a-z0-9_-]*)="((?:[^"\\]|\\.)*)"/g, h = /^:::[ \t]*$/, A = /* @__PURE__ */ new Set(["note", "tip", "important", "caution", "warning"]), f = (t) => t.type === "text" && typeof t.value == "string" ? t.value : t.type === "break" ? `
2
+ ` : (t.type === "inlineCode" || t.type === "html") && typeof t.value == "string" ? t.value : Array.isArray(t.children) && t.children.length > 0 ? t.children.map(f).join("") : "", p = (t) => {
3
+ if (t.type !== "paragraph" || !t.children || t.children.length === 0) return null;
4
+ const n = t.children.map(f).join("");
5
+ return n.length > 0 ? n : null;
6
+ }, T = (t) => {
7
+ if (t.type !== "paragraph" || !Array.isArray(t.children)) return [];
8
+ const n = [[]], r = () => {
9
+ n.push([]);
10
+ }, i = (e) => {
11
+ n[n.length - 1].push(e);
12
+ };
13
+ for (const e of t.children) {
14
+ if (e.type === "break") {
15
+ r();
7
16
  continue;
8
17
  }
9
- if (e.type === "break") {
10
- t += `
11
- `;
18
+ if (e.type === "text" && typeof e.value == "string" && e.value.includes(`
19
+ `)) {
20
+ const s = e.value.split(/\r?\n/);
21
+ s.forEach((l, c) => {
22
+ l.length > 0 && i({ type: "text", value: l }), c < s.length - 1 && r();
23
+ });
12
24
  continue;
13
25
  }
14
- return null;
26
+ i(e);
15
27
  }
16
- return t;
17
- }, T = (n) => ({
18
- type: "paragraph",
19
- children: [{ type: "text", value: n }]
20
- }), _ = (n) => n.replace(/\\(.)/g, "$1"), v = (n) => {
21
- if (!y.test(n)) return null;
22
- const t = {};
23
- for (const e of n.matchAll(x)) {
24
- const i = e[1], o = _(e[2]);
25
- (i === "icon" || i === "title") && (t[i] = o);
28
+ return n;
29
+ }, b = (t) => t.replace(/\\(.)/g, "$1"), E = (t) => {
30
+ if (!v.test(t)) return null;
31
+ const n = {};
32
+ for (const r of t.matchAll(x)) {
33
+ const i = r[1], e = b(r[2]);
34
+ (i === "icon" || i === "title") && (n[i] = e);
26
35
  }
27
- return t;
28
- }, E = (n) => {
29
- let t = !1, e = !1;
30
- for (let i = 1; i < n.length; i += 1) {
31
- const o = n[i];
32
- if (e) {
33
- e = !1;
36
+ return n;
37
+ }, I = (t) => {
38
+ let n = !1, r = !1;
39
+ for (let i = 1; i < t.length; i += 1) {
40
+ const e = t[i];
41
+ if (r) {
42
+ r = !1;
34
43
  continue;
35
44
  }
36
- if (o === "\\") {
37
- e = !0;
45
+ if (e === "\\") {
46
+ r = !0;
38
47
  continue;
39
48
  }
40
- if (o === '"') {
41
- t = !t;
49
+ if (e === '"') {
50
+ n = !n;
42
51
  continue;
43
52
  }
44
- if (o === "}" && !t)
53
+ if (e === "}" && !n)
45
54
  return i;
46
55
  }
47
56
  return -1;
48
- }, I = (n) => {
49
- if (!n.startsWith(":::")) return null;
50
- let t = n.slice(3);
51
- const e = t.match(g);
52
- if (!e) return null;
53
- const i = e[0];
54
- t = t.slice(i.length);
55
- let o;
56
- if (t.startsWith("[")) {
57
- const r = t.indexOf("]");
58
- if (r < 0) return null;
59
- o = t.slice(1, r), t = t.slice(r + 1);
57
+ }, N = (t) => {
58
+ if (!t.startsWith(":::")) return null;
59
+ let n = t.slice(3);
60
+ const r = n.match(y);
61
+ if (!r) return null;
62
+ const i = r[0];
63
+ n = n.slice(i.length);
64
+ let e;
65
+ if (n.startsWith("[")) {
66
+ const l = n.indexOf("]");
67
+ if (l < 0) return null;
68
+ e = n.slice(1, l), n = n.slice(l + 1);
60
69
  }
61
- let c = {};
62
- if (t.startsWith("{")) {
63
- const r = E(t);
64
- if (r < 0) return null;
65
- const a = v(t.slice(1, r));
66
- if (!a) return null;
67
- c = a, t = t.slice(r + 1);
70
+ let s = {};
71
+ if (n.startsWith("{")) {
72
+ const l = I(n);
73
+ if (l < 0) return null;
74
+ const c = E(n.slice(1, l));
75
+ if (!c) return null;
76
+ s = c, n = n.slice(l + 1);
68
77
  }
69
- return /^[ \t]*$/.test(t) ? { name: i, title: o, attributes: c } : null;
70
- }, A = (n, t) => {
71
- for (let e = t; e < n.length; e += 1) {
72
- const i = f(n[e]);
73
- if (i && d.test(i))
74
- return e;
78
+ return /^[ \t]*$/.test(n) ? { name: i, title: e, attributes: s } : null;
79
+ }, _ = (t, n) => {
80
+ for (let r = n; r < t.length; r += 1) {
81
+ const i = p(t[r]);
82
+ if (i && h.test(i))
83
+ return r;
75
84
  }
76
85
  return -1;
77
- }, N = (n) => {
78
- const t = n.join(`
79
- `);
80
- return t.trim() ? t.split(/\n{2,}/).map((e) => e.trim()).filter(Boolean).map((e) => T(e)) : [];
86
+ }, z = (t, n) => {
87
+ const r = T(t);
88
+ return r.length ? r.slice(1, n).filter((i) => i.some((e) => f(e).trim().length > 0)).map((i) => ({
89
+ type: "paragraph",
90
+ children: i
91
+ })) : [];
81
92
  };
82
- function z() {
83
- return (n) => {
84
- if (!(!n || n.type !== "root" || !Array.isArray(n.children)))
85
- for (let t = 0; t < n.children.length; t += 1) {
86
- const e = f(n.children[t]);
93
+ function R() {
94
+ return (t) => {
95
+ if (!(!t || t.type !== "root" || !Array.isArray(t.children)))
96
+ for (let n = 0; n < t.children.length; n += 1) {
97
+ const r = p(t.children[n]);
98
+ if (!r) continue;
99
+ const i = r.split(/\r?\n/), e = N(i[0] ?? "");
87
100
  if (!e) continue;
88
- const i = e.split(/\r?\n/), o = I(i[0] ?? "");
89
- if (!o) continue;
90
- let c = [], r = 0;
101
+ let s = [], l = 0;
91
102
  if (i.length > 1) {
92
- const l = i.findIndex((u, m) => m > 0 && d.test(u));
93
- if (l < 0 || i.slice(l + 1).some((u) => u.trim().length > 0))
103
+ const o = i.findIndex((u, m) => m > 0 && h.test(u));
104
+ if (o < 0 || i.slice(o + 1).some((u) => u.trim().length > 0))
94
105
  continue;
95
- c = N(i.slice(1, l)), r = 1;
106
+ s = z(t.children[n], o), l = 1;
96
107
  } else {
97
- const l = A(n.children, t + 1);
98
- if (l < 0) continue;
99
- c = n.children.slice(t + 1, l), r = l - t + 1;
108
+ const o = _(t.children, n + 1);
109
+ if (o < 0) continue;
110
+ s = t.children.slice(n + 1, o), l = o - n + 1;
100
111
  }
101
- const a = o.title ?? o.attributes.title, h = b.has(o.name) ? o.name : "unknown", s = {
102
- "data-admonition": o.name,
103
- "data-admonition-variant": h
112
+ const c = e.title ?? e.attributes.title, d = A.has(e.name) ? e.name : "unknown", a = {
113
+ "data-admonition": e.name,
114
+ "data-admonition-variant": d
104
115
  };
105
- a !== void 0 && (s["data-admonition-title"] = a), o.attributes.icon !== void 0 && (s["data-admonition-icon"] = o.attributes.icon);
106
- const p = {
116
+ c !== void 0 && (a["data-admonition-title"] = c), e.attributes.icon !== void 0 && (a["data-admonition-icon"] = e.attributes.icon);
117
+ const g = {
107
118
  type: "admonition",
108
119
  data: {
109
120
  hName: "aside",
110
- hProperties: s
121
+ hProperties: a
111
122
  },
112
- children: c
123
+ children: s
113
124
  };
114
- n.children.splice(t, r, p);
125
+ t.children.splice(n, l, g);
115
126
  }
116
127
  };
117
128
  }
118
129
  export {
119
- z as remarkAdmonition
130
+ R as remarkAdmonition
120
131
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.196",
4
+ "version": "0.0.197",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",