@regmisatyam/retex 0.1.0
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/LICENSE +21 -0
- package/README.md +492 -0
- package/dist/index.cjs +3444 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +916 -0
- package/dist/index.d.ts +916 -0
- package/dist/index.js +3370 -0
- package/dist/index.js.map +1 -0
- package/dist/react-v8gyKEAs.d.cts +420 -0
- package/dist/react-v8gyKEAs.d.ts +420 -0
- package/dist/react.cjs +805 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +802 -0
- package/dist/react.js.map +1 -0
- package/package.json +85 -0
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/theme/default.ts
|
|
4
|
+
var defaultTheme = {
|
|
5
|
+
name: "default",
|
|
6
|
+
colors: {
|
|
7
|
+
primary: "#2563eb",
|
|
8
|
+
secondary: "#64748b",
|
|
9
|
+
text: "#1e293b",
|
|
10
|
+
muted: "#64748b",
|
|
11
|
+
background: "#ffffff",
|
|
12
|
+
border: "#e2e8f0",
|
|
13
|
+
accent: "#2563eb",
|
|
14
|
+
success: "#16a34a"
|
|
15
|
+
},
|
|
16
|
+
fonts: {
|
|
17
|
+
heading: '"Inter", "Helvetica Neue", Helvetica, Arial, sans-serif',
|
|
18
|
+
body: '"Inter", "Helvetica Neue", Helvetica, Arial, sans-serif',
|
|
19
|
+
mono: '"JetBrains Mono", "SF Mono", "Fira Code", Consolas, monospace'
|
|
20
|
+
},
|
|
21
|
+
fontSizes: {
|
|
22
|
+
base: "10.5pt",
|
|
23
|
+
small: "9pt",
|
|
24
|
+
large: "12pt",
|
|
25
|
+
Large: "15pt",
|
|
26
|
+
Huge: "22pt",
|
|
27
|
+
name: "26pt",
|
|
28
|
+
section: "13pt"
|
|
29
|
+
},
|
|
30
|
+
spacing: {
|
|
31
|
+
unit: "4px",
|
|
32
|
+
section: "1.1rem",
|
|
33
|
+
item: "0.28rem",
|
|
34
|
+
page: "0.55in"
|
|
35
|
+
},
|
|
36
|
+
page: {
|
|
37
|
+
size: "Letter",
|
|
38
|
+
margin: "0.55in",
|
|
39
|
+
maxWidth: "8.5in"
|
|
40
|
+
},
|
|
41
|
+
sectionStyle: "rule"
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/theme/themes.ts
|
|
45
|
+
function resolveTheme(partial, base = defaultTheme) {
|
|
46
|
+
if (!partial) return base;
|
|
47
|
+
return {
|
|
48
|
+
name: partial.name ?? base.name,
|
|
49
|
+
colors: { ...base.colors, ...partial.colors },
|
|
50
|
+
fonts: { ...base.fonts, ...partial.fonts },
|
|
51
|
+
fontSizes: { ...base.fontSizes, ...partial.fontSizes },
|
|
52
|
+
spacing: { ...base.spacing, ...partial.spacing },
|
|
53
|
+
page: { ...base.page, ...partial.page },
|
|
54
|
+
sectionStyle: partial.sectionStyle ?? base.sectionStyle
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
resolveTheme({
|
|
58
|
+
name: "modern",
|
|
59
|
+
colors: { primary: "#7c3aed", accent: "#7c3aed", text: "#111827" },
|
|
60
|
+
sectionStyle: "underline"
|
|
61
|
+
});
|
|
62
|
+
resolveTheme({
|
|
63
|
+
name: "classic",
|
|
64
|
+
colors: { primary: "#111827", secondary: "#4b5563", accent: "#111827" },
|
|
65
|
+
fonts: {
|
|
66
|
+
heading: 'Georgia, "Times New Roman", serif',
|
|
67
|
+
body: 'Georgia, "Times New Roman", serif',
|
|
68
|
+
mono: 'Consolas, "Courier New", monospace'
|
|
69
|
+
},
|
|
70
|
+
sectionStyle: "rule"
|
|
71
|
+
});
|
|
72
|
+
resolveTheme({
|
|
73
|
+
name: "compact",
|
|
74
|
+
fontSizes: {
|
|
75
|
+
base: "9.5pt",
|
|
76
|
+
small: "8pt",
|
|
77
|
+
large: "11pt",
|
|
78
|
+
Large: "13pt",
|
|
79
|
+
Huge: "18pt",
|
|
80
|
+
name: "20pt",
|
|
81
|
+
section: "11pt"
|
|
82
|
+
},
|
|
83
|
+
spacing: { unit: "3px", section: "0.7rem", item: "0.18rem", page: "0.4in" },
|
|
84
|
+
sectionStyle: "bar"
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// src/security/sanitize.ts
|
|
88
|
+
var SAFE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:", "ftp:", "sms:"]);
|
|
89
|
+
var SCHEME_RE = /^([a-z][a-z0-9+.-]*):/i;
|
|
90
|
+
var CONTROL_CHARS_RE = /[\x00-\x1f\x7f]/g;
|
|
91
|
+
function sanitizeUrl(input) {
|
|
92
|
+
const raw = String(input ?? "").trim();
|
|
93
|
+
const cleaned = raw.replace(CONTROL_CHARS_RE, "");
|
|
94
|
+
const match = SCHEME_RE.exec(cleaned);
|
|
95
|
+
if (!match) {
|
|
96
|
+
return { safe: cleaned, blocked: false };
|
|
97
|
+
}
|
|
98
|
+
const scheme = match[1].toLowerCase() + ":";
|
|
99
|
+
if (SAFE_PROTOCOLS.has(scheme)) {
|
|
100
|
+
return { safe: cleaned, blocked: false, scheme };
|
|
101
|
+
}
|
|
102
|
+
return { safe: "#", blocked: true, scheme };
|
|
103
|
+
}
|
|
104
|
+
function isSafeColor(value) {
|
|
105
|
+
const v = value.trim();
|
|
106
|
+
if (/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(v)) return true;
|
|
107
|
+
if (/^(rgb|rgba|hsl|hsla)\(\s*[0-9.,%\s/]+\)$/i.test(v)) return true;
|
|
108
|
+
return CSS_NAMED_COLORS.has(v.toLowerCase());
|
|
109
|
+
}
|
|
110
|
+
function isSafeDimension(value) {
|
|
111
|
+
return /^-?\d*\.?\d+(px|pt|em|rem|ex|ch|vw|vh|vmin|vmax|cm|mm|in|pc|%|fr)?$/.test(
|
|
112
|
+
value.trim()
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function sanitizeStyleValue(value) {
|
|
116
|
+
const v = value.trim();
|
|
117
|
+
if (/[<>;{}]/.test(v) || /expression|url\s*\(|javascript:/i.test(v)) {
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
120
|
+
return v;
|
|
121
|
+
}
|
|
122
|
+
var CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
123
|
+
"black",
|
|
124
|
+
"silver",
|
|
125
|
+
"gray",
|
|
126
|
+
"grey",
|
|
127
|
+
"white",
|
|
128
|
+
"maroon",
|
|
129
|
+
"red",
|
|
130
|
+
"purple",
|
|
131
|
+
"fuchsia",
|
|
132
|
+
"green",
|
|
133
|
+
"lime",
|
|
134
|
+
"olive",
|
|
135
|
+
"yellow",
|
|
136
|
+
"navy",
|
|
137
|
+
"blue",
|
|
138
|
+
"teal",
|
|
139
|
+
"aqua",
|
|
140
|
+
"cyan",
|
|
141
|
+
"magenta",
|
|
142
|
+
"orange",
|
|
143
|
+
"pink",
|
|
144
|
+
"brown",
|
|
145
|
+
"gold",
|
|
146
|
+
"indigo",
|
|
147
|
+
"violet",
|
|
148
|
+
"tan",
|
|
149
|
+
"beige",
|
|
150
|
+
"ivory",
|
|
151
|
+
"coral",
|
|
152
|
+
"salmon",
|
|
153
|
+
"khaki",
|
|
154
|
+
"crimson",
|
|
155
|
+
"turquoise",
|
|
156
|
+
"lavender",
|
|
157
|
+
"plum",
|
|
158
|
+
"orchid",
|
|
159
|
+
"slateblue",
|
|
160
|
+
"slategray",
|
|
161
|
+
"steelblue",
|
|
162
|
+
"skyblue",
|
|
163
|
+
"royalblue",
|
|
164
|
+
"midnightblue",
|
|
165
|
+
"darkblue",
|
|
166
|
+
"darkgreen",
|
|
167
|
+
"darkred",
|
|
168
|
+
"darkgray",
|
|
169
|
+
"darkgrey",
|
|
170
|
+
"lightgray",
|
|
171
|
+
"lightgrey",
|
|
172
|
+
"lightblue",
|
|
173
|
+
"transparent",
|
|
174
|
+
"currentcolor",
|
|
175
|
+
"inherit"
|
|
176
|
+
]);
|
|
177
|
+
|
|
178
|
+
// src/icons/icons.ts
|
|
179
|
+
var ICONS = {
|
|
180
|
+
github: {
|
|
181
|
+
body: '<path d="M12 1.5A10.5 10.5 0 0 0 8.7 22c.5.1.7-.2.7-.5v-2c-2.9.6-3.5-1.3-3.5-1.3-.5-1.2-1.2-1.5-1.2-1.5-.9-.6.1-.6.1-.6 1 .1 1.6 1 1.6 1 .9 1.6 2.4 1.1 3 .9.1-.7.4-1.1.7-1.4-2.3-.3-4.8-1.2-4.8-5.2 0-1.2.4-2.1 1-2.9-.1-.3-.5-1.3.1-2.7 0 0 .9-.3 2.8 1.1a9.6 9.6 0 0 1 5 0c1.9-1.4 2.8-1.1 2.8-1.1.6 1.4.2 2.4.1 2.7.7.8 1 1.7 1 2.9 0 4-2.5 4.9-4.8 5.2.4.3.7 1 .7 2v3c0 .3.2.6.7.5A10.5 10.5 0 0 0 12 1.5Z"/>'
|
|
182
|
+
},
|
|
183
|
+
linkedin: {
|
|
184
|
+
body: '<path d="M20.5 2h-17A1.5 1.5 0 0 0 2 3.5v17A1.5 1.5 0 0 0 3.5 22h17a1.5 1.5 0 0 0 1.5-1.5v-17A1.5 1.5 0 0 0 20.5 2ZM8 19H5v-9h3v9ZM6.5 8.7A1.7 1.7 0 1 1 6.5 5.3a1.7 1.7 0 0 1 0 3.4ZM19 19h-3v-4.7c0-1.1 0-2.6-1.6-2.6s-1.8 1.2-1.8 2.5V19h-3v-9h2.9v1.2h.04a3.2 3.2 0 0 1 2.9-1.6c3.1 0 3.7 2 3.7 4.7V19Z"/>'
|
|
185
|
+
},
|
|
186
|
+
email: {
|
|
187
|
+
body: '<path d="M3 5h18a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Zm.4 2 8.6 6 8.6-6H3.4ZM20 8.2l-7.4 5.2a1 1 0 0 1-1.2 0L4 8.2V17h16V8.2Z"/>',
|
|
188
|
+
aliases: ["mail", "envelope"]
|
|
189
|
+
},
|
|
190
|
+
phone: {
|
|
191
|
+
body: '<path d="M6.6 10.8a15.5 15.5 0 0 0 6.6 6.6l2.2-2.2a1 1 0 0 1 1-.25 11.4 11.4 0 0 0 3.6.58 1 1 0 0 1 1 1V20a1 1 0 0 1-1 1A17 17 0 0 1 3 4a1 1 0 0 1 1-1h3.5a1 1 0 0 1 1 1 11.4 11.4 0 0 0 .57 3.6 1 1 0 0 1-.25 1l-2.2 2.2Z"/>',
|
|
192
|
+
aliases: ["tel", "telephone"]
|
|
193
|
+
},
|
|
194
|
+
location: {
|
|
195
|
+
body: '<path d="M12 2a7 7 0 0 0-7 7c0 5 7 13 7 13s7-8 7-13a7 7 0 0 0-7-7Zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5Z"/>',
|
|
196
|
+
aliases: ["map", "pin", "marker", "geo"]
|
|
197
|
+
},
|
|
198
|
+
website: {
|
|
199
|
+
body: '<path d="M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm6.9 6h-2.9a15.7 15.7 0 0 0-1.3-3.4A8 8 0 0 1 18.9 8ZM12 4c.8 1.1 1.5 2.5 1.9 4h-3.8c.4-1.5 1.1-2.9 1.9-4ZM4.3 14a8 8 0 0 1 0-4h3.3a17.6 17.6 0 0 0 0 4H4.3Zm.8 2h2.9a15.7 15.7 0 0 0 1.3 3.4A8 8 0 0 1 5.1 16Zm2.9-8H5.1a8 8 0 0 1 4.2-3.4A15.7 15.7 0 0 0 8 8Zm4 12c-.8-1.1-1.5-2.5-1.9-4h3.8c-.4 1.5-1.1 2.9-1.9 4Zm2.3-6h-4.6a15.3 15.3 0 0 1 0-4h4.6a15.3 15.3 0 0 1 0 4Zm.4 5.4a15.7 15.7 0 0 0 1.3-3.4h2.9a8 8 0 0 1-4.2 3.4ZM16.4 14a17.6 17.6 0 0 0 0-4h3.3a8 8 0 0 1 0 4h-3.3Z"/>',
|
|
200
|
+
aliases: ["globe", "web", "link", "url"]
|
|
201
|
+
},
|
|
202
|
+
twitter: {
|
|
203
|
+
body: '<path d="M22 5.9c-.7.3-1.5.6-2.3.7a4 4 0 0 0 1.8-2.2c-.8.5-1.7.8-2.6 1a4 4 0 0 0-6.8 3.6A11.3 11.3 0 0 1 3.9 4.8a4 4 0 0 0 1.2 5.3c-.6 0-1.2-.2-1.8-.5a4 4 0 0 0 3.2 3.9c-.6.1-1.2.2-1.8.1a4 4 0 0 0 3.7 2.8A8 8 0 0 1 2 18.1 11.3 11.3 0 0 0 8.1 20c7.4 0 11.5-6.2 11.5-11.5v-.5c.8-.6 1.5-1.3 2-2.1Z"/>',
|
|
204
|
+
aliases: ["x"]
|
|
205
|
+
},
|
|
206
|
+
gitlab: {
|
|
207
|
+
body: '<path d="m21.9 13.1-1.1-3.4-2.2-6.8a.6.6 0 0 0-1.1 0l-2.2 6.8H8.7L6.5 2.9a.6.6 0 0 0-1.1 0L3.2 9.7l-1.1 3.4a1.2 1.2 0 0 0 .4 1.3l9.5 6.9 9.5-6.9a1.2 1.2 0 0 0 .4-1.3Z"/>'
|
|
208
|
+
},
|
|
209
|
+
stackoverflow: {
|
|
210
|
+
body: '<path d="M17 21v-6h2v8H4v-8h2v6h11ZM7 17h9v-2H7v2Zm.3-4.2 8.8 1.8.4-2-8.8-1.8-.4 2Zm1.2-4.4 8.1 3.8.8-1.8-8.1-3.8-.8 1.8Zm2.5-4 6.9 5.7 1.3-1.5-6.9-5.7-1.3 1.5ZM15.6 1l-1.6 1.2 5.3 7.2 1.6-1.2L15.6 1Z"/>',
|
|
211
|
+
aliases: ["stack-overflow", "so"]
|
|
212
|
+
},
|
|
213
|
+
scholar: {
|
|
214
|
+
body: '<path d="M12 2 1 9l11 7 9-5.7V17h2V9L12 2ZM5 14.2V18c0 1.7 3.1 3 7 3s7-1.3 7-3v-3.8l-7 4.4-7-4.4Z"/>',
|
|
215
|
+
aliases: ["google-scholar", "academic"]
|
|
216
|
+
},
|
|
217
|
+
orcid: {
|
|
218
|
+
body: '<path d="M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20ZM8.5 7.6a1.1 1.1 0 1 1 0 2.2 1.1 1.1 0 0 1 0-2.2ZM9.5 17h-2v-6.2h2V17Zm2-6.2h3.3c2.2 0 3.6 1.5 3.6 3.1 0 1.8-1.4 3.1-3.6 3.1H11.5v-6.2Zm2 1.7v2.8h1.1c1.2 0 1.8-.6 1.8-1.4s-.6-1.4-1.8-1.4h-1.1Z"/>'
|
|
219
|
+
},
|
|
220
|
+
calendar: {
|
|
221
|
+
body: '<path d="M7 2v2H5a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2V2h-2v2H9V2H7ZM5 9h14v10H5V9Z"/>',
|
|
222
|
+
aliases: ["date"]
|
|
223
|
+
},
|
|
224
|
+
briefcase: {
|
|
225
|
+
body: '<path d="M9 3a2 2 0 0 0-2 2v1H4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-3V5a2 2 0 0 0-2-2H9Zm0 3V5h6v1H9Z"/>',
|
|
226
|
+
aliases: ["work", "job"]
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var ALIASES = {};
|
|
230
|
+
for (const [name, def] of Object.entries(ICONS)) {
|
|
231
|
+
for (const alias of def.aliases ?? []) ALIASES[alias] = name;
|
|
232
|
+
}
|
|
233
|
+
function resolveIconName(name) {
|
|
234
|
+
const key = name.trim().toLowerCase();
|
|
235
|
+
if (ICONS[key]) return key;
|
|
236
|
+
if (ALIASES[key]) return ALIASES[key];
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
function getIcon(name) {
|
|
240
|
+
const key = resolveIconName(name);
|
|
241
|
+
return key ? ICONS[key] : void 0;
|
|
242
|
+
}
|
|
243
|
+
function iconToSvg(name, opts = {}) {
|
|
244
|
+
const def = getIcon(name);
|
|
245
|
+
if (!def) return null;
|
|
246
|
+
const size = opts.size ?? "1em";
|
|
247
|
+
const dim = typeof size === "number" ? `${size}` : size;
|
|
248
|
+
const cls = opts.className ? ` class="${opts.className}"` : "";
|
|
249
|
+
const fillOrStroke = def.stroked ? 'fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"' : 'fill="currentColor"';
|
|
250
|
+
return `<svg${cls} width="${dim}" height="${dim}" viewBox="0 0 24 24" ${fillOrStroke} role="img" aria-hidden="true" focusable="false">${def.body}</svg>`;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/renderers/css.ts
|
|
254
|
+
var tokenSafe = (s) => s.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
255
|
+
function themeToCss(theme, prefix = "retex") {
|
|
256
|
+
const p = prefix;
|
|
257
|
+
const colorVars = Object.entries(theme.colors).map(([k, v]) => ` --${p}-color-${tokenSafe(k)}: ${v};`).join("\n");
|
|
258
|
+
return `.${p}-resume {
|
|
259
|
+
${colorVars}
|
|
260
|
+
--${p}-primary: ${theme.colors.primary};
|
|
261
|
+
--${p}-text: ${theme.colors.text};
|
|
262
|
+
--${p}-muted: ${theme.colors.muted};
|
|
263
|
+
--${p}-border: ${theme.colors.border};
|
|
264
|
+
--${p}-bg: ${theme.colors.background};
|
|
265
|
+
--${p}-font-heading: ${theme.fonts.heading};
|
|
266
|
+
--${p}-font-body: ${theme.fonts.body};
|
|
267
|
+
--${p}-font-mono: ${theme.fonts.mono};
|
|
268
|
+
--${p}-fs-base: ${theme.fontSizes.base};
|
|
269
|
+
--${p}-fs-small: ${theme.fontSizes.small};
|
|
270
|
+
--${p}-fs-large: ${theme.fontSizes.large};
|
|
271
|
+
--${p}-fs-Large: ${theme.fontSizes.Large};
|
|
272
|
+
--${p}-fs-Huge: ${theme.fontSizes.Huge};
|
|
273
|
+
--${p}-fs-name: ${theme.fontSizes.name};
|
|
274
|
+
--${p}-fs-section: ${theme.fontSizes.section};
|
|
275
|
+
--${p}-sp-section: ${theme.spacing.section};
|
|
276
|
+
--${p}-sp-item: ${theme.spacing.item};
|
|
277
|
+
|
|
278
|
+
box-sizing: border-box;
|
|
279
|
+
max-width: ${theme.page.maxWidth};
|
|
280
|
+
margin: 0 auto;
|
|
281
|
+
padding: ${theme.spacing.page};
|
|
282
|
+
background: var(--${p}-bg);
|
|
283
|
+
color: var(--${p}-text);
|
|
284
|
+
font-family: var(--${p}-font-body);
|
|
285
|
+
font-size: var(--${p}-fs-base);
|
|
286
|
+
line-height: 1.45;
|
|
287
|
+
}
|
|
288
|
+
.${p}-resume *, .${p}-resume *::before, .${p}-resume *::after { box-sizing: border-box; }
|
|
289
|
+
|
|
290
|
+
.${p}-header { margin-bottom: var(--${p}-sp-section); }
|
|
291
|
+
.${p}-name {
|
|
292
|
+
font-family: var(--${p}-font-heading);
|
|
293
|
+
font-size: var(--${p}-fs-name);
|
|
294
|
+
font-weight: 700;
|
|
295
|
+
margin: 0 0 0.1em;
|
|
296
|
+
color: var(--${p}-text);
|
|
297
|
+
letter-spacing: -0.01em;
|
|
298
|
+
}
|
|
299
|
+
.${p}-title {
|
|
300
|
+
font-size: var(--${p}-fs-large);
|
|
301
|
+
color: var(--${p}-primary);
|
|
302
|
+
margin: 0 0 0.45em;
|
|
303
|
+
font-weight: 500;
|
|
304
|
+
}
|
|
305
|
+
.${p}-contact {
|
|
306
|
+
display: flex;
|
|
307
|
+
flex-wrap: wrap;
|
|
308
|
+
gap: 0.35rem 1rem;
|
|
309
|
+
font-size: var(--${p}-fs-small);
|
|
310
|
+
color: var(--${p}-muted);
|
|
311
|
+
}
|
|
312
|
+
.${p}-contact-item {
|
|
313
|
+
display: inline-flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
gap: 0.3em;
|
|
316
|
+
color: inherit;
|
|
317
|
+
text-decoration: none;
|
|
318
|
+
}
|
|
319
|
+
.${p}-contact-item svg { opacity: 0.8; }
|
|
320
|
+
|
|
321
|
+
.${p}-section { margin-bottom: var(--${p}-sp-section); break-inside: avoid; }
|
|
322
|
+
.${p}-section-title {
|
|
323
|
+
font-family: var(--${p}-font-heading);
|
|
324
|
+
font-size: var(--${p}-fs-section);
|
|
325
|
+
font-weight: 700;
|
|
326
|
+
text-transform: uppercase;
|
|
327
|
+
letter-spacing: 0.06em;
|
|
328
|
+
color: var(--${p}-primary);
|
|
329
|
+
margin: 0 0 0.5em;
|
|
330
|
+
}
|
|
331
|
+
.${p}-section--rule .${p}-section-title { border-bottom: 2px solid var(--${p}-border); padding-bottom: 0.2em; }
|
|
332
|
+
.${p}-section--underline .${p}-section-title { text-decoration: underline; text-underline-offset: 3px; }
|
|
333
|
+
.${p}-section--bar .${p}-section-title {
|
|
334
|
+
border-left: 3px solid var(--${p}-primary);
|
|
335
|
+
padding-left: 0.5em;
|
|
336
|
+
border-bottom: none;
|
|
337
|
+
}
|
|
338
|
+
.${p}-subsection-title {
|
|
339
|
+
font-family: var(--${p}-font-heading);
|
|
340
|
+
font-size: var(--${p}-fs-large);
|
|
341
|
+
font-weight: 600;
|
|
342
|
+
margin: 0.6em 0 0.3em;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.${p}-entry { margin-bottom: 0.6rem; break-inside: avoid; }
|
|
346
|
+
.${p}-entry-row {
|
|
347
|
+
display: flex;
|
|
348
|
+
justify-content: space-between;
|
|
349
|
+
align-items: baseline;
|
|
350
|
+
gap: 1rem;
|
|
351
|
+
}
|
|
352
|
+
.${p}-entry-title { font-weight: 700; }
|
|
353
|
+
.${p}-entry-subtitle { color: var(--${p}-primary); font-weight: 500; }
|
|
354
|
+
.${p}-entry-dates, .${p}-entry-location {
|
|
355
|
+
color: var(--${p}-muted);
|
|
356
|
+
font-size: var(--${p}-fs-small);
|
|
357
|
+
white-space: nowrap;
|
|
358
|
+
}
|
|
359
|
+
.${p}-entry-body { margin-top: 0.15rem; }
|
|
360
|
+
.${p}-entry-body p { margin: 0.2em 0; }
|
|
361
|
+
|
|
362
|
+
.${p}-list { margin: 0.2rem 0 0.2rem 1.1rem; padding: 0; }
|
|
363
|
+
.${p}-list li { margin-bottom: var(--${p}-sp-item); padding-left: 0.15rem; }
|
|
364
|
+
|
|
365
|
+
.${p}-columns { display: flex; gap: 1.5rem; align-items: flex-start; }
|
|
366
|
+
.${p}-column { min-width: 0; }
|
|
367
|
+
|
|
368
|
+
.${p}-skills { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0.2rem 0; padding: 0; }
|
|
369
|
+
.${p}-skill {
|
|
370
|
+
background: color-mix(in srgb, var(--${p}-primary) 12%, transparent);
|
|
371
|
+
color: var(--${p}-primary);
|
|
372
|
+
border-radius: 4px;
|
|
373
|
+
padding: 0.12rem 0.5rem;
|
|
374
|
+
font-size: var(--${p}-fs-small);
|
|
375
|
+
font-weight: 500;
|
|
376
|
+
white-space: nowrap;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.${p}-link { color: var(--${p}-primary); text-decoration: none; }
|
|
380
|
+
.${p}-link:hover { text-decoration: underline; }
|
|
381
|
+
.${p}-icon { display: inline-flex; vertical-align: -0.125em; }
|
|
382
|
+
.${p}-rule { border: none; border-top: 1px solid var(--${p}-border); margin: 0.6rem 0; }
|
|
383
|
+
.${p}-center { text-align: center; }
|
|
384
|
+
.${p}-scale-small { font-size: var(--${p}-fs-small); }
|
|
385
|
+
.${p}-scale-large { font-size: var(--${p}-fs-large); }
|
|
386
|
+
.${p}-scale-Large { font-size: var(--${p}-fs-Large); }
|
|
387
|
+
.${p}-scale-Huge { font-size: var(--${p}-fs-Huge); }
|
|
388
|
+
p.${p}-para { margin: 0 0 0.45em; }
|
|
389
|
+
p.${p}-para:last-child { margin-bottom: 0; }
|
|
390
|
+
|
|
391
|
+
@media print {
|
|
392
|
+
.${p}-resume { max-width: none; margin: 0; padding: 0; }
|
|
393
|
+
.${p}-section, .${p}-entry { break-inside: avoid; }
|
|
394
|
+
a { color: inherit; }
|
|
395
|
+
}`;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// src/renderers/context.ts
|
|
399
|
+
var BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
400
|
+
"section",
|
|
401
|
+
"job",
|
|
402
|
+
"education",
|
|
403
|
+
"project",
|
|
404
|
+
"skills",
|
|
405
|
+
"list",
|
|
406
|
+
"columns",
|
|
407
|
+
"rule"
|
|
408
|
+
]);
|
|
409
|
+
function isBlockNode(node) {
|
|
410
|
+
if (BLOCK_TYPES.has(node.type)) return true;
|
|
411
|
+
if (node.type === "space") return node.axis === "vertical";
|
|
412
|
+
if (node.type === "command" && node.name === "center") return true;
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/renderers/structure.ts
|
|
417
|
+
function toRegions(children) {
|
|
418
|
+
const regions = [{ nodes: [] }];
|
|
419
|
+
for (const node of children) {
|
|
420
|
+
if (node.type === "section" && node.level === 1) {
|
|
421
|
+
regions.push({ section: node, nodes: [] });
|
|
422
|
+
} else {
|
|
423
|
+
regions[regions.length - 1].nodes.push(node);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return regions;
|
|
427
|
+
}
|
|
428
|
+
var CONTACTISH = /* @__PURE__ */ new Set(["contact", "icon", "link", "url"]);
|
|
429
|
+
function splitPreamble(nodes) {
|
|
430
|
+
const name = nodes.find(
|
|
431
|
+
(n) => n.type === "contact" && n.field === "name"
|
|
432
|
+
);
|
|
433
|
+
const title = nodes.find(
|
|
434
|
+
(n) => n.type === "contact" && n.field === "title"
|
|
435
|
+
);
|
|
436
|
+
const contacts = nodes.filter(
|
|
437
|
+
(n) => CONTACTISH.has(n.type) && n !== name && n !== title
|
|
438
|
+
);
|
|
439
|
+
const other = nodes.filter(
|
|
440
|
+
(n) => !CONTACTISH.has(n.type) && n.type !== "parbreak" && !(n.type === "text" && n.value.trim() === "")
|
|
441
|
+
);
|
|
442
|
+
return { name, title, contacts, other };
|
|
443
|
+
}
|
|
444
|
+
function entryParts(fields, kind) {
|
|
445
|
+
let title;
|
|
446
|
+
let subtitle;
|
|
447
|
+
if (kind === "education") {
|
|
448
|
+
title = fields.school ?? fields.degree ?? "";
|
|
449
|
+
subtitle = fields.school ? fields.degree ?? "" : "";
|
|
450
|
+
} else if (kind === "project") {
|
|
451
|
+
title = fields.name ?? fields.title ?? "";
|
|
452
|
+
subtitle = fields.organization ?? fields.tech ?? "";
|
|
453
|
+
} else {
|
|
454
|
+
title = fields.title ?? fields.role ?? fields.name ?? "";
|
|
455
|
+
subtitle = fields.company ?? fields.organization ?? "";
|
|
456
|
+
}
|
|
457
|
+
return {
|
|
458
|
+
title,
|
|
459
|
+
subtitle,
|
|
460
|
+
dates: dateRange(fields.start, fields.end, fields.date),
|
|
461
|
+
location: fields.location ?? "",
|
|
462
|
+
url: fields.url ?? fields.link ?? ""
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
function dateRange(start, end, date) {
|
|
466
|
+
if (date) return date;
|
|
467
|
+
if (start && end) return `${start} \u2013 ${end}`;
|
|
468
|
+
return start ?? end ?? "";
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// src/renderers/react.ts
|
|
472
|
+
var tokenSafe2 = (s) => s.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
473
|
+
var ReactRenderer = class {
|
|
474
|
+
constructor(options) {
|
|
475
|
+
this.key = 0;
|
|
476
|
+
if (typeof options.createElement !== "function") {
|
|
477
|
+
throw new TypeError(
|
|
478
|
+
"ReactRenderer requires a `createElement` factory (e.g. React.createElement)."
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
this.theme = options.theme ?? resolveTheme();
|
|
482
|
+
this.prefix = options.classPrefix ?? "retex";
|
|
483
|
+
this.h = options.createElement;
|
|
484
|
+
this.Fragment = options.Fragment ?? "div";
|
|
485
|
+
this.overrides = options.overrides ?? /* @__PURE__ */ new Map();
|
|
486
|
+
this.useHeader = options.header ?? true;
|
|
487
|
+
}
|
|
488
|
+
/** The stylesheet for the active theme. Render it in a `<style>` yourself. */
|
|
489
|
+
styles() {
|
|
490
|
+
return themeToCss(this.theme, this.prefix);
|
|
491
|
+
}
|
|
492
|
+
/** Render the document AST to a React element. */
|
|
493
|
+
render(ast) {
|
|
494
|
+
const regions = toRegions(ast.children);
|
|
495
|
+
const parts = [];
|
|
496
|
+
const preamble = regions[0]?.section ? void 0 : regions.shift();
|
|
497
|
+
if (preamble) parts.push(...this.renderPreamble(preamble.nodes));
|
|
498
|
+
for (const region of regions) {
|
|
499
|
+
if (region.section) parts.push(this.renderSection(region.section, region.nodes));
|
|
500
|
+
else parts.push(...this.renderFlow(region.nodes));
|
|
501
|
+
}
|
|
502
|
+
return this.el("div", { className: this.cls("resume") }, parts);
|
|
503
|
+
}
|
|
504
|
+
ctx() {
|
|
505
|
+
return {
|
|
506
|
+
theme: this.theme,
|
|
507
|
+
classPrefix: this.prefix,
|
|
508
|
+
h: this.h,
|
|
509
|
+
Fragment: this.Fragment,
|
|
510
|
+
overrides: this.overrides,
|
|
511
|
+
renderNodes: (nodes) => this.renderFlow(nodes),
|
|
512
|
+
cls: (name) => this.cls(name)
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/* --------------------------- structuring ---------------------------- */
|
|
516
|
+
renderSection(section, body) {
|
|
517
|
+
return this.el(
|
|
518
|
+
"section",
|
|
519
|
+
{
|
|
520
|
+
className: `${this.cls("section")} ${this.cls("section")}--${this.theme.sectionStyle}`
|
|
521
|
+
},
|
|
522
|
+
[
|
|
523
|
+
this.el("h2", { className: this.cls("section-title") }, [section.title]),
|
|
524
|
+
this.el("div", { className: this.cls("section-body") }, this.renderFlow(body))
|
|
525
|
+
]
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
renderPreamble(nodes) {
|
|
529
|
+
if (!this.useHeader) return this.renderFlow(nodes);
|
|
530
|
+
const { name, title, contacts, other } = splitPreamble(nodes);
|
|
531
|
+
const out = [];
|
|
532
|
+
if (name || title || contacts.length > 0) {
|
|
533
|
+
const head = [];
|
|
534
|
+
if (name) head.push(this.el("h1", { className: this.cls("name") }, [name.value]));
|
|
535
|
+
if (title) head.push(this.el("p", { className: this.cls("title") }, [title.value]));
|
|
536
|
+
if (contacts.length > 0) {
|
|
537
|
+
head.push(
|
|
538
|
+
this.el(
|
|
539
|
+
"div",
|
|
540
|
+
{ className: this.cls("contact") },
|
|
541
|
+
contacts.map((c) => this.renderNode(c))
|
|
542
|
+
)
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
out.push(this.el("header", { className: this.cls("header") }, head));
|
|
546
|
+
}
|
|
547
|
+
if (other.length > 0) out.push(...this.renderFlow(other));
|
|
548
|
+
return out;
|
|
549
|
+
}
|
|
550
|
+
/* ----------------------------- flow / inline ------------------------ */
|
|
551
|
+
renderFlow(nodes) {
|
|
552
|
+
const out = [];
|
|
553
|
+
let inline = [];
|
|
554
|
+
const flush = () => {
|
|
555
|
+
if (inline.length === 0) return;
|
|
556
|
+
const meaningful = inline.some((n) => n.type !== "text" || n.value.trim() !== "");
|
|
557
|
+
if (meaningful) {
|
|
558
|
+
out.push(
|
|
559
|
+
this.el("p", { className: this.cls("para") }, this.renderInline(inline))
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
inline = [];
|
|
563
|
+
};
|
|
564
|
+
for (const node of nodes) {
|
|
565
|
+
if (node.type === "parbreak") flush();
|
|
566
|
+
else if (isBlockNode(node)) {
|
|
567
|
+
flush();
|
|
568
|
+
out.push(this.renderNode(node));
|
|
569
|
+
} else inline.push(node);
|
|
570
|
+
}
|
|
571
|
+
flush();
|
|
572
|
+
return out;
|
|
573
|
+
}
|
|
574
|
+
renderInline(nodes) {
|
|
575
|
+
return nodes.map((n) => this.renderNode(n));
|
|
576
|
+
}
|
|
577
|
+
/* ------------------------------ per node ---------------------------- */
|
|
578
|
+
renderNode(node) {
|
|
579
|
+
const override = this.overrides.get(node.type) ?? (node.type === "command" ? this.overrides.get(`command:${node.name}`) : void 0);
|
|
580
|
+
if (override) return override(node, this.ctx(), (ns) => this.renderFlow(ns));
|
|
581
|
+
switch (node.type) {
|
|
582
|
+
case "text":
|
|
583
|
+
return node.value;
|
|
584
|
+
case "parbreak":
|
|
585
|
+
return null;
|
|
586
|
+
case "linebreak":
|
|
587
|
+
return this.el("br", null, []);
|
|
588
|
+
case "rule":
|
|
589
|
+
return this.el("hr", { className: this.cls("rule") }, []);
|
|
590
|
+
case "space":
|
|
591
|
+
return node.axis === "vertical" ? this.el("div", { style: { height: this.dim(node.size) } }, []) : this.el(
|
|
592
|
+
"span",
|
|
593
|
+
{ style: { display: "inline-block", width: this.dim(node.size) } },
|
|
594
|
+
[]
|
|
595
|
+
);
|
|
596
|
+
case "group":
|
|
597
|
+
return this.frag(this.renderInline(node.children));
|
|
598
|
+
case "bold":
|
|
599
|
+
return this.el("strong", null, this.renderInline(node.children));
|
|
600
|
+
case "italic":
|
|
601
|
+
return this.el("em", null, this.renderInline(node.children));
|
|
602
|
+
case "underline":
|
|
603
|
+
return this.el("u", null, this.renderInline(node.children));
|
|
604
|
+
case "strike":
|
|
605
|
+
return this.el("s", null, this.renderInline(node.children));
|
|
606
|
+
case "color": {
|
|
607
|
+
const inner = this.renderInline(node.children);
|
|
608
|
+
if (!node.color || !isSafeColor(node.color)) return this.frag(inner);
|
|
609
|
+
return this.el("span", { style: { color: node.color } }, inner);
|
|
610
|
+
}
|
|
611
|
+
case "themecolor":
|
|
612
|
+
return this.el(
|
|
613
|
+
"span",
|
|
614
|
+
{
|
|
615
|
+
style: {
|
|
616
|
+
color: `var(--${this.prefix}-color-${tokenSafe2(node.token)}, currentColor)`
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
this.renderInline(node.children)
|
|
620
|
+
);
|
|
621
|
+
case "fontsize": {
|
|
622
|
+
const inner = this.renderInline(node.children);
|
|
623
|
+
if (!isSafeDimension(node.size)) return this.frag(inner);
|
|
624
|
+
return this.el("span", { style: { fontSize: node.size } }, inner);
|
|
625
|
+
}
|
|
626
|
+
case "fontfamily": {
|
|
627
|
+
const inner = this.renderInline(node.children);
|
|
628
|
+
const family = node.family === "monospace" ? `var(--${this.prefix}-font-mono)` : sanitizeStyleValue(node.family);
|
|
629
|
+
if (!family) return this.frag(inner);
|
|
630
|
+
return this.el("span", { style: { fontFamily: family } }, inner);
|
|
631
|
+
}
|
|
632
|
+
case "fontscale":
|
|
633
|
+
return node.scale === "normal" ? this.frag(this.renderInline(node.children)) : this.el(
|
|
634
|
+
"span",
|
|
635
|
+
{ className: this.cls(`scale-${node.scale}`) },
|
|
636
|
+
this.renderInline(node.children)
|
|
637
|
+
);
|
|
638
|
+
case "link":
|
|
639
|
+
return this.renderLink(node.href, this.renderInline(node.children));
|
|
640
|
+
case "url":
|
|
641
|
+
return this.renderLink(node.href, [node.rawHref]);
|
|
642
|
+
case "icon":
|
|
643
|
+
return this.renderIcon(node.name);
|
|
644
|
+
case "section":
|
|
645
|
+
return this.el(
|
|
646
|
+
`h${node.level + 1}`,
|
|
647
|
+
{ className: this.cls("subsection-title") },
|
|
648
|
+
[node.title]
|
|
649
|
+
);
|
|
650
|
+
case "list":
|
|
651
|
+
return this.renderList(node);
|
|
652
|
+
case "columns":
|
|
653
|
+
return this.renderColumns(node);
|
|
654
|
+
case "skills":
|
|
655
|
+
return this.el(
|
|
656
|
+
"ul",
|
|
657
|
+
{ className: this.cls("skills") },
|
|
658
|
+
node.items.map((s) => this.el("li", { className: this.cls("skill") }, [s]))
|
|
659
|
+
);
|
|
660
|
+
case "job":
|
|
661
|
+
return this.renderEntry(node, "job");
|
|
662
|
+
case "education":
|
|
663
|
+
return this.renderEntry(node, "education");
|
|
664
|
+
case "project":
|
|
665
|
+
return this.renderEntry(node, "project");
|
|
666
|
+
case "contact":
|
|
667
|
+
return this.renderContact(node);
|
|
668
|
+
case "command":
|
|
669
|
+
return this.renderCommand(node);
|
|
670
|
+
default:
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
renderContact(node) {
|
|
675
|
+
const item = this.cls("contact-item");
|
|
676
|
+
switch (node.field) {
|
|
677
|
+
case "email":
|
|
678
|
+
return this.contactLink(`mailto:${node.value}`, "email", node.value, item);
|
|
679
|
+
case "phone":
|
|
680
|
+
return this.contactLink(
|
|
681
|
+
`tel:${node.value.replace(/[^\d+]/g, "")}`,
|
|
682
|
+
"phone",
|
|
683
|
+
node.value,
|
|
684
|
+
item
|
|
685
|
+
);
|
|
686
|
+
case "website":
|
|
687
|
+
return this.contactLink(node.value, "website", node.value, item);
|
|
688
|
+
case "location":
|
|
689
|
+
return this.el("span", { className: item }, [
|
|
690
|
+
this.renderIcon("location"),
|
|
691
|
+
node.value
|
|
692
|
+
]);
|
|
693
|
+
default:
|
|
694
|
+
return this.el("span", { className: item }, [node.value]);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
contactLink(url, icon, label, cls) {
|
|
698
|
+
const { safe } = sanitizeUrl(url);
|
|
699
|
+
return this.el("a", { className: cls, href: safe }, [this.renderIcon(icon), label]);
|
|
700
|
+
}
|
|
701
|
+
renderLink(href, label) {
|
|
702
|
+
const { safe } = sanitizeUrl(href);
|
|
703
|
+
const external = /^https?:/i.test(safe);
|
|
704
|
+
const props = { className: this.cls("link"), href: safe };
|
|
705
|
+
if (external) {
|
|
706
|
+
props.target = "_blank";
|
|
707
|
+
props.rel = "noopener noreferrer";
|
|
708
|
+
}
|
|
709
|
+
return this.el("a", props, label);
|
|
710
|
+
}
|
|
711
|
+
renderList(node) {
|
|
712
|
+
const tag = node.kind === "enumerate" ? "ol" : "ul";
|
|
713
|
+
return this.el(
|
|
714
|
+
tag,
|
|
715
|
+
{ className: this.cls("list") },
|
|
716
|
+
node.items.map((item) => this.el("li", null, this.renderInline(item.children)))
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
renderColumns(node) {
|
|
720
|
+
return this.el(
|
|
721
|
+
"div",
|
|
722
|
+
{ className: this.cls("columns") },
|
|
723
|
+
node.columns.map((col) => {
|
|
724
|
+
const basis = isSafeDimension(col.width) ? col.width : "auto";
|
|
725
|
+
const style = basis === "auto" ? { flex: "1 1 0" } : { flex: `0 0 ${basis}` };
|
|
726
|
+
return this.el(
|
|
727
|
+
"div",
|
|
728
|
+
{ className: this.cls("column"), style },
|
|
729
|
+
this.renderFlow(col.children)
|
|
730
|
+
);
|
|
731
|
+
})
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
renderEntry(node, kind) {
|
|
735
|
+
const { title, subtitle, dates, location, url } = entryParts(node.fields, kind);
|
|
736
|
+
const rows = [];
|
|
737
|
+
const titleEl = url ? this.renderLink(sanitizeUrl(url).safe, [title]) : title;
|
|
738
|
+
rows.push(
|
|
739
|
+
this.el("div", { className: this.cls("entry-row") }, [
|
|
740
|
+
this.el("span", { className: this.cls("entry-title") }, [titleEl]),
|
|
741
|
+
dates ? this.el("span", { className: this.cls("entry-dates") }, [dates]) : null
|
|
742
|
+
])
|
|
743
|
+
);
|
|
744
|
+
if (subtitle || location) {
|
|
745
|
+
rows.push(
|
|
746
|
+
this.el("div", { className: this.cls("entry-row") }, [
|
|
747
|
+
this.el("span", { className: this.cls("entry-subtitle") }, [subtitle]),
|
|
748
|
+
location ? this.el("span", { className: this.cls("entry-location") }, [location]) : null
|
|
749
|
+
])
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
if (node.children.length > 0) {
|
|
753
|
+
rows.push(
|
|
754
|
+
this.el(
|
|
755
|
+
"div",
|
|
756
|
+
{ className: this.cls("entry-body") },
|
|
757
|
+
this.renderFlow(node.children)
|
|
758
|
+
)
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
return this.el("div", { className: `${this.cls("entry")} ${this.cls(kind)}` }, rows);
|
|
762
|
+
}
|
|
763
|
+
renderCommand(node) {
|
|
764
|
+
const inner = node.args.flatMap((a) => a.children);
|
|
765
|
+
if (node.name === "center") {
|
|
766
|
+
return this.el("div", { className: this.cls("center") }, this.renderFlow(inner));
|
|
767
|
+
}
|
|
768
|
+
return this.frag(this.renderInline(inner));
|
|
769
|
+
}
|
|
770
|
+
renderIcon(name) {
|
|
771
|
+
const svg = iconToSvg(name);
|
|
772
|
+
if (!svg) return this.el("span", { className: this.cls("icon"), title: name }, []);
|
|
773
|
+
return this.el(
|
|
774
|
+
"span",
|
|
775
|
+
{
|
|
776
|
+
className: this.cls("icon"),
|
|
777
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
778
|
+
},
|
|
779
|
+
[]
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
/* ------------------------------ helpers ----------------------------- */
|
|
783
|
+
el(type, props, children) {
|
|
784
|
+
const filtered = children.filter((c) => c !== null && c !== void 0 && c !== "");
|
|
785
|
+
const finalProps = { ...props ?? {}, key: this.key++ };
|
|
786
|
+
return this.h(type, finalProps, ...filtered);
|
|
787
|
+
}
|
|
788
|
+
frag(children) {
|
|
789
|
+
return this.el(this.Fragment, null, children);
|
|
790
|
+
}
|
|
791
|
+
dim(value) {
|
|
792
|
+
return isSafeDimension(value) ? value : "0";
|
|
793
|
+
}
|
|
794
|
+
cls(name) {
|
|
795
|
+
return `${this.prefix}-${name}`;
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
function renderReact(ast, options) {
|
|
799
|
+
return new ReactRenderer(options).render(ast);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
exports.ReactRenderer = ReactRenderer;
|
|
803
|
+
exports.renderReact = renderReact;
|
|
804
|
+
//# sourceMappingURL=react.cjs.map
|
|
805
|
+
//# sourceMappingURL=react.cjs.map
|