@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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 === "
|
|
10
|
-
|
|
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
|
-
|
|
26
|
+
i(e);
|
|
15
27
|
}
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
28
|
-
},
|
|
29
|
-
let
|
|
30
|
-
for (let i = 1; i <
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
|
|
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 (
|
|
37
|
-
|
|
45
|
+
if (e === "\\") {
|
|
46
|
+
r = !0;
|
|
38
47
|
continue;
|
|
39
48
|
}
|
|
40
|
-
if (
|
|
41
|
-
|
|
49
|
+
if (e === '"') {
|
|
50
|
+
n = !n;
|
|
42
51
|
continue;
|
|
43
52
|
}
|
|
44
|
-
if (
|
|
53
|
+
if (e === "}" && !n)
|
|
45
54
|
return i;
|
|
46
55
|
}
|
|
47
56
|
return -1;
|
|
48
|
-
},
|
|
49
|
-
if (!
|
|
50
|
-
let
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
-
const i =
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
|
|
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
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
|
|
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(
|
|
70
|
-
},
|
|
71
|
-
for (let
|
|
72
|
-
const i =
|
|
73
|
-
if (i &&
|
|
74
|
-
return
|
|
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
|
-
},
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
83
|
-
return (
|
|
84
|
-
if (!(!
|
|
85
|
-
for (let
|
|
86
|
-
const
|
|
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
|
-
|
|
89
|
-
if (!o) continue;
|
|
90
|
-
let c = [], r = 0;
|
|
101
|
+
let s = [], l = 0;
|
|
91
102
|
if (i.length > 1) {
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
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
|
-
|
|
106
|
+
s = z(t.children[n], o), l = 1;
|
|
96
107
|
} else {
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
|
|
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
|
|
102
|
-
"data-admonition":
|
|
103
|
-
"data-admonition-variant":
|
|
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
|
-
|
|
106
|
-
const
|
|
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:
|
|
121
|
+
hProperties: a
|
|
111
122
|
},
|
|
112
|
-
children:
|
|
123
|
+
children: s
|
|
113
124
|
};
|
|
114
|
-
|
|
125
|
+
t.children.splice(n, l, g);
|
|
115
126
|
}
|
|
116
127
|
};
|
|
117
128
|
}
|
|
118
129
|
export {
|
|
119
|
-
|
|
130
|
+
R as remarkAdmonition
|
|
120
131
|
};
|