@changerawr/markdown 1.0.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.
@@ -0,0 +1,1791 @@
1
+ "use client";
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/react/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ MarkdownRenderer: () => MarkdownRenderer2,
35
+ useMarkdown: () => useMarkdown,
36
+ useMarkdownDebug: () => useMarkdownDebug,
37
+ useMarkdownEngine: () => useMarkdownEngine
38
+ });
39
+ module.exports = __toCommonJS(index_exports);
40
+
41
+ // src/react/MarkdownRenderer.tsx
42
+ var import_react2 = __toESM(require("react"));
43
+
44
+ // src/react/hooks.ts
45
+ var import_react = require("react");
46
+
47
+ // src/parser.ts
48
+ var MarkdownParser = class {
49
+ constructor(config) {
50
+ this.rules = [];
51
+ this.warnings = [];
52
+ this.config = config || {};
53
+ }
54
+ addRule(rule) {
55
+ this.rules.push(rule);
56
+ this.rules.sort((a, b) => {
57
+ if (a.name.includes("alert") || a.name.includes("embed") || a.name.includes("button")) return -1;
58
+ if (b.name.includes("alert") || b.name.includes("embed") || b.name.includes("button")) return 1;
59
+ if (a.name === "task-list") return -1;
60
+ if (b.name === "task-list") return 1;
61
+ if (a.name === "list" && b.name === "task-list") return 1;
62
+ if (b.name === "list" && a.name === "task-list") return -1;
63
+ return a.name.localeCompare(b.name);
64
+ });
65
+ }
66
+ setupDefaultRulesIfEmpty() {
67
+ const hasDefaultRules = this.rules.some(
68
+ (rule) => !["alert", "button", "embed"].includes(rule.name)
69
+ );
70
+ if (!hasDefaultRules) {
71
+ this.setupDefaultRules();
72
+ }
73
+ }
74
+ hasRule(name) {
75
+ return this.rules.some((rule) => rule.name === name);
76
+ }
77
+ parse(markdown2) {
78
+ this.warnings = [];
79
+ this.setupDefaultRulesIfEmpty();
80
+ const processedMarkdown = this.preprocessMarkdown(markdown2);
81
+ const tokens = [];
82
+ let remaining = processedMarkdown;
83
+ let iterationCount = 0;
84
+ const maxIterations = this.config.maxIterations || markdown2.length * 2;
85
+ while (remaining.length > 0 && iterationCount < maxIterations) {
86
+ iterationCount++;
87
+ let matched = false;
88
+ let bestMatch = null;
89
+ for (const rule of this.rules) {
90
+ try {
91
+ const pattern = new RegExp(rule.pattern.source, rule.pattern.flags.replace("g", ""));
92
+ const match = remaining.match(pattern);
93
+ if (match && match.index !== void 0) {
94
+ const priority = match.index === 0 ? 1e3 : 1e3 - match.index;
95
+ if (!bestMatch || priority > bestMatch.priority || priority === bestMatch.priority && match.index < (bestMatch.match.index || 0)) {
96
+ bestMatch = { rule, match, priority };
97
+ }
98
+ }
99
+ } catch (error) {
100
+ if (this.config.debugMode) {
101
+ console.warn(`Error in rule "${rule.name}":`, error);
102
+ }
103
+ }
104
+ }
105
+ if (bestMatch && bestMatch.match.index !== void 0) {
106
+ const { rule, match } = bestMatch;
107
+ const matchIndex = match.index;
108
+ if (matchIndex > 0) {
109
+ const textBefore = remaining.slice(0, matchIndex);
110
+ tokens.push({
111
+ type: "text",
112
+ content: textBefore,
113
+ raw: textBefore
114
+ });
115
+ remaining = remaining.slice(matchIndex);
116
+ continue;
117
+ }
118
+ try {
119
+ const token = rule.render(match);
120
+ tokens.push({
121
+ ...token,
122
+ raw: match[0] || ""
123
+ });
124
+ remaining = remaining.slice(match[0]?.length || 0);
125
+ matched = true;
126
+ } catch (error) {
127
+ const errorMessage = error instanceof Error ? error.message : String(error);
128
+ this.warnings.push(`Failed to render ${rule.name}: ${errorMessage}`);
129
+ const char = remaining[0];
130
+ if (char) {
131
+ tokens.push({
132
+ type: "text",
133
+ content: char,
134
+ raw: char
135
+ });
136
+ remaining = remaining.slice(1);
137
+ }
138
+ }
139
+ }
140
+ if (!matched) {
141
+ const char = remaining[0];
142
+ if (char) {
143
+ tokens.push({
144
+ type: "text",
145
+ content: char,
146
+ raw: char
147
+ });
148
+ remaining = remaining.slice(1);
149
+ }
150
+ }
151
+ }
152
+ if (iterationCount >= maxIterations) {
153
+ this.warnings.push("Parser hit maximum iterations - possible infinite loop detected");
154
+ }
155
+ const processedTokens = this.postProcessTokens(tokens);
156
+ return processedTokens;
157
+ }
158
+ getWarnings() {
159
+ return [...this.warnings];
160
+ }
161
+ getConfig() {
162
+ return { ...this.config };
163
+ }
164
+ updateConfig(config) {
165
+ this.config = { ...this.config, ...config };
166
+ }
167
+ setDebugMode(enabled) {
168
+ this.config.debugMode = enabled;
169
+ }
170
+ clearWarnings() {
171
+ this.warnings = [];
172
+ }
173
+ getIterationCount() {
174
+ return 0;
175
+ }
176
+ preprocessMarkdown(markdown2) {
177
+ if (this.config.validateMarkdown) {
178
+ this.validateMarkdown(markdown2);
179
+ }
180
+ return markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
181
+ }
182
+ validateMarkdown(markdown2) {
183
+ const boldMatches = markdown2.match(/\*\*/g);
184
+ if (boldMatches && boldMatches.length % 2 !== 0) {
185
+ this.warnings.push("Unclosed bold markers (**) detected - some bold formatting may not work");
186
+ }
187
+ const italicMatches = markdown2.match(/(?<!\*)\*(?!\*)/g);
188
+ if (italicMatches && italicMatches.length % 2 !== 0) {
189
+ this.warnings.push("Unclosed italic markers (*) detected - some italic formatting may not work");
190
+ }
191
+ const codeBlockMatches = markdown2.match(/```/g);
192
+ if (codeBlockMatches && codeBlockMatches.length % 2 !== 0) {
193
+ this.warnings.push("Unclosed code blocks (```) detected - some code formatting may not work");
194
+ }
195
+ const inlineCodeMatches = markdown2.match(/`/g);
196
+ if (inlineCodeMatches && inlineCodeMatches.length % 2 !== 0) {
197
+ this.warnings.push("Unclosed inline code markers (`) detected - some code formatting may not work");
198
+ }
199
+ }
200
+ postProcessTokens(tokens) {
201
+ const processed = [];
202
+ let i = 0;
203
+ while (i < tokens.length) {
204
+ const token = tokens[i];
205
+ if (token && token.type === "text") {
206
+ let textContent = token.content || token.raw || "";
207
+ let j = i + 1;
208
+ while (j < tokens.length && tokens[j] && tokens[j].type === "text") {
209
+ const nextToken = tokens[j];
210
+ textContent += nextToken.content || nextToken.raw || "";
211
+ j++;
212
+ }
213
+ if (textContent.trim().length > 0 || textContent.includes("\n")) {
214
+ processed.push({
215
+ type: "text",
216
+ content: textContent,
217
+ raw: textContent
218
+ });
219
+ }
220
+ i = j;
221
+ } else if (token) {
222
+ processed.push(token);
223
+ i++;
224
+ } else {
225
+ i++;
226
+ }
227
+ }
228
+ return processed;
229
+ }
230
+ setupDefaultRules() {
231
+ this.addRule({
232
+ name: "heading",
233
+ pattern: /^(#{1,6})\s+(.+)$/m,
234
+ render: (match) => ({
235
+ type: "heading",
236
+ content: match[2]?.trim() || "",
237
+ raw: match[0] || "",
238
+ attributes: {
239
+ level: String(match[1]?.length || 1)
240
+ }
241
+ })
242
+ });
243
+ this.addRule({
244
+ name: "codeblock",
245
+ pattern: /```(\w+)?\s*\n([\s\S]*?)\n```/,
246
+ render: (match) => ({
247
+ type: "codeblock",
248
+ content: match[2] || "",
249
+ raw: match[0] || "",
250
+ attributes: {
251
+ language: match[1] || "text"
252
+ }
253
+ })
254
+ });
255
+ this.addRule({
256
+ name: "hard-break-backslash",
257
+ pattern: /\\\s*\n/,
258
+ render: (match) => ({
259
+ type: "line-break",
260
+ content: "",
261
+ raw: match[0] || ""
262
+ })
263
+ });
264
+ this.addRule({
265
+ name: "hard-break-spaces",
266
+ pattern: / +\n/,
267
+ render: (match) => ({
268
+ type: "line-break",
269
+ content: "",
270
+ raw: match[0] || ""
271
+ })
272
+ });
273
+ this.addRule({
274
+ name: "paragraph-break",
275
+ pattern: /\n\s*\n/,
276
+ render: (match) => ({
277
+ type: "paragraph-break",
278
+ content: "",
279
+ raw: match[0] || ""
280
+ })
281
+ });
282
+ this.addRule({
283
+ name: "bold",
284
+ pattern: /\*\*((?:(?!\*\*).)+)\*\*/,
285
+ render: (match) => ({
286
+ type: "bold",
287
+ content: match[1] || "",
288
+ raw: match[0] || ""
289
+ })
290
+ });
291
+ this.addRule({
292
+ name: "italic",
293
+ pattern: /\*((?:(?!\*).)+)\*/,
294
+ render: (match) => ({
295
+ type: "italic",
296
+ content: match[1] || "",
297
+ raw: match[0] || ""
298
+ })
299
+ });
300
+ this.addRule({
301
+ name: "code",
302
+ pattern: /`([^`]+)`/,
303
+ render: (match) => ({
304
+ type: "code",
305
+ content: match[1] || "",
306
+ raw: match[0] || ""
307
+ })
308
+ });
309
+ this.addRule({
310
+ name: "image",
311
+ pattern: /!\[([^\]]*)\]\(([^)]+?)(?:\s+"([^"]+)")?\)/,
312
+ render: (match) => ({
313
+ type: "image",
314
+ content: match[1] || "",
315
+ raw: match[0] || "",
316
+ attributes: {
317
+ alt: match[1] || "",
318
+ src: match[2] || "",
319
+ title: match[3] || ""
320
+ }
321
+ })
322
+ });
323
+ this.addRule({
324
+ name: "link",
325
+ pattern: /\[([^\]]+)\]\(([^)]+)\)/,
326
+ render: (match) => ({
327
+ type: "link",
328
+ content: match[1] || "",
329
+ raw: match[0] || "",
330
+ attributes: {
331
+ href: match[2] || ""
332
+ }
333
+ })
334
+ });
335
+ this.addRule({
336
+ name: "task-list",
337
+ pattern: /^(\s*)-\s*\[([ xX])\]\s*(.+)$/m,
338
+ render: (match) => ({
339
+ type: "task-item",
340
+ content: match[3] || "",
341
+ raw: match[0] || "",
342
+ attributes: {
343
+ checked: String((match[2] || "").toLowerCase() === "x")
344
+ }
345
+ })
346
+ });
347
+ this.addRule({
348
+ name: "list",
349
+ pattern: /^(\s*)[-*+]\s+(.+)$/m,
350
+ render: (match) => ({
351
+ type: "list-item",
352
+ content: match[2] || "",
353
+ raw: match[0] || ""
354
+ })
355
+ });
356
+ this.addRule({
357
+ name: "blockquote",
358
+ pattern: /^>\s+(.+)$/m,
359
+ render: (match) => ({
360
+ type: "blockquote",
361
+ content: match[1] || "",
362
+ raw: match[0] || ""
363
+ })
364
+ });
365
+ this.addRule({
366
+ name: "hr",
367
+ pattern: /^---$/m,
368
+ render: (match) => ({
369
+ type: "hr",
370
+ content: "",
371
+ raw: match[0] || ""
372
+ })
373
+ });
374
+ this.addRule({
375
+ name: "soft-break",
376
+ pattern: /\n/,
377
+ render: (match) => ({
378
+ type: "soft-break",
379
+ content: " ",
380
+ // Convert to space for inline text
381
+ raw: match[0] || ""
382
+ })
383
+ });
384
+ }
385
+ };
386
+
387
+ // src/utils.ts
388
+ var DOMPurify = {
389
+ sanitize: (html) => html
390
+ };
391
+ if (typeof window !== "undefined") {
392
+ import("dompurify").then((module2) => {
393
+ DOMPurify = module2.default;
394
+ }).catch((err) => {
395
+ console.error("Failed to load DOMPurify", err);
396
+ });
397
+ }
398
+ var ALLOWED_TAGS = [
399
+ // Standard HTML
400
+ "h1",
401
+ "h2",
402
+ "h3",
403
+ "h4",
404
+ "h5",
405
+ "h6",
406
+ "p",
407
+ "br",
408
+ "strong",
409
+ "em",
410
+ "del",
411
+ "ins",
412
+ "a",
413
+ "img",
414
+ "ul",
415
+ "ol",
416
+ "li",
417
+ "blockquote",
418
+ "pre",
419
+ "code",
420
+ "table",
421
+ "thead",
422
+ "tbody",
423
+ "tr",
424
+ "th",
425
+ "td",
426
+ "div",
427
+ "span",
428
+ "sup",
429
+ "sub",
430
+ "hr",
431
+ "input",
432
+ // Embeds
433
+ "iframe",
434
+ "embed",
435
+ "object",
436
+ "param",
437
+ "video",
438
+ "audio",
439
+ "source",
440
+ // SVG
441
+ "svg",
442
+ "path",
443
+ "polyline",
444
+ "line",
445
+ "circle",
446
+ "rect",
447
+ "g",
448
+ "defs",
449
+ "use",
450
+ // Form elements
451
+ "form",
452
+ "fieldset",
453
+ "legend",
454
+ "label",
455
+ "select",
456
+ "option",
457
+ "textarea",
458
+ "button"
459
+ ];
460
+ var ALLOWED_ATTR = [
461
+ // Standard attributes
462
+ "href",
463
+ "title",
464
+ "alt",
465
+ "src",
466
+ "class",
467
+ "id",
468
+ "target",
469
+ "rel",
470
+ "type",
471
+ "checked",
472
+ "disabled",
473
+ "loading",
474
+ "width",
475
+ "height",
476
+ "style",
477
+ "role",
478
+ // Iframe attributes
479
+ "frameborder",
480
+ "allowfullscreen",
481
+ "allow",
482
+ "sandbox",
483
+ "scrolling",
484
+ "allowtransparency",
485
+ "name",
486
+ "seamless",
487
+ "srcdoc",
488
+ // Data attributes (for embeds)
489
+ "data-*",
490
+ // SVG attributes
491
+ "viewBox",
492
+ "fill",
493
+ "stroke",
494
+ "stroke-width",
495
+ "stroke-linecap",
496
+ "stroke-linejoin",
497
+ "d",
498
+ "points",
499
+ "x1",
500
+ "y1",
501
+ "x2",
502
+ "y2",
503
+ "cx",
504
+ "cy",
505
+ "r",
506
+ "rx",
507
+ "ry",
508
+ // Media attributes
509
+ "autoplay",
510
+ "controls",
511
+ "loop",
512
+ "muted",
513
+ "preload",
514
+ "poster",
515
+ // Form attributes
516
+ "value",
517
+ "placeholder",
518
+ "required",
519
+ "readonly",
520
+ "maxlength",
521
+ "minlength",
522
+ "max",
523
+ "min",
524
+ "step",
525
+ "pattern",
526
+ "autocomplete",
527
+ "autofocus"
528
+ ];
529
+ function escapeHtml(text) {
530
+ const map = {
531
+ "&": "&amp;",
532
+ "<": "&lt;",
533
+ ">": "&gt;",
534
+ '"': "&quot;",
535
+ "'": "&#39;"
536
+ };
537
+ return text.replace(/[&<>"']/g, (char) => map[char] || char);
538
+ }
539
+ function generateId(text) {
540
+ return text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").trim();
541
+ }
542
+ function sanitizeHtml(html) {
543
+ try {
544
+ if (html.includes("codepen.io/") || html.includes("youtube.com/embed/")) {
545
+ return html;
546
+ }
547
+ if (typeof DOMPurify?.sanitize === "function") {
548
+ const sanitized = DOMPurify.sanitize(html, {
549
+ ALLOWED_TAGS,
550
+ ALLOWED_ATTR,
551
+ ALLOW_DATA_ATTR: true,
552
+ ALLOW_UNKNOWN_PROTOCOLS: false,
553
+ SAFE_FOR_TEMPLATES: false,
554
+ WHOLE_DOCUMENT: false,
555
+ RETURN_DOM: false,
556
+ RETURN_DOM_FRAGMENT: false,
557
+ FORCE_BODY: false,
558
+ SANITIZE_DOM: false,
559
+ SANITIZE_NAMED_PROPS: false,
560
+ FORBID_ATTR: ["onload", "onerror", "onclick", "onmouseover", "onmouseout", "onfocus", "onblur"],
561
+ ADD_TAGS: ["iframe", "embed", "object", "param"],
562
+ ADD_ATTR: [
563
+ "allow",
564
+ "allowfullscreen",
565
+ "frameborder",
566
+ "scrolling",
567
+ "allowtransparency",
568
+ "sandbox",
569
+ "loading",
570
+ "style",
571
+ "title",
572
+ "name",
573
+ "seamless",
574
+ "srcdoc"
575
+ ],
576
+ ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|xxx):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
577
+ });
578
+ if (sanitized.length < html.length * 0.7) {
579
+ return basicSanitize(html);
580
+ }
581
+ return sanitized;
582
+ }
583
+ return basicSanitize(html);
584
+ } catch (error) {
585
+ console.error("Sanitization failed:", error);
586
+ return basicSanitize(html);
587
+ }
588
+ }
589
+ function basicSanitize(html) {
590
+ return html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/on\w+\s*=\s*"[^"]*"/gi, "").replace(/on\w+\s*=\s*'[^']*'/gi, "").replace(/javascript:/gi, "");
591
+ }
592
+ function extractDomain(url) {
593
+ try {
594
+ return new URL(url).hostname;
595
+ } catch {
596
+ return url;
597
+ }
598
+ }
599
+ function parseOptions(options) {
600
+ const parsed = {};
601
+ if (!options) return parsed;
602
+ options.split(",").forEach((option) => {
603
+ const [key, value] = option.split(":").map((s) => s.trim());
604
+ if (key && value) {
605
+ parsed[key] = value;
606
+ }
607
+ });
608
+ return parsed;
609
+ }
610
+
611
+ // src/renderer.ts
612
+ var MarkdownRenderer = class {
613
+ constructor(config) {
614
+ this.rules = /* @__PURE__ */ new Map();
615
+ this.warnings = [];
616
+ this.config = {
617
+ format: "tailwind",
618
+ sanitize: true,
619
+ allowUnsafeHtml: false,
620
+ debugMode: false,
621
+ ...config
622
+ };
623
+ this.setupDefaultRules();
624
+ }
625
+ addRule(rule) {
626
+ this.rules.set(rule.type, rule);
627
+ }
628
+ hasRule(type) {
629
+ return this.rules.has(type);
630
+ }
631
+ render(tokens) {
632
+ this.warnings = [];
633
+ const htmlParts = tokens.map((token) => this.renderToken(token));
634
+ const combinedHtml = htmlParts.join("");
635
+ if (this.config.sanitize && !this.config.allowUnsafeHtml) {
636
+ return sanitizeHtml(combinedHtml);
637
+ }
638
+ return combinedHtml;
639
+ }
640
+ getWarnings() {
641
+ return [...this.warnings];
642
+ }
643
+ getConfig() {
644
+ return { ...this.config };
645
+ }
646
+ updateConfig(config) {
647
+ this.config = { ...this.config, ...config };
648
+ }
649
+ setDebugMode(enabled) {
650
+ this.config.debugMode = enabled;
651
+ }
652
+ clearWarnings() {
653
+ this.warnings = [];
654
+ }
655
+ renderToken(token) {
656
+ const rule = this.rules.get(token.type);
657
+ if (rule) {
658
+ try {
659
+ return rule.render(token);
660
+ } catch (error) {
661
+ const errorMessage = error instanceof Error ? error.message : String(error);
662
+ this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
663
+ return this.createErrorBlock(`Render error for ${token.type}: ${errorMessage}`);
664
+ }
665
+ }
666
+ if (token.type === "text") {
667
+ return escapeHtml(token.content || token.raw || "");
668
+ }
669
+ if (this.config.debugMode) {
670
+ return this.createDebugBlock(token);
671
+ }
672
+ return escapeHtml(token.content || token.raw || "");
673
+ }
674
+ createErrorBlock(message) {
675
+ if (this.config.format === "html") {
676
+ return `<div style="background-color: #fee; border: 1px solid #fcc; color: #c66; padding: 8px; border-radius: 4px; margin: 8px 0; font-size: 14px;">
677
+ <strong>Render Error:</strong> ${escapeHtml(message)}
678
+ </div>`;
679
+ }
680
+ return `<div class="bg-red-100 border border-red-300 text-red-800 p-2 rounded text-sm mb-2">
681
+ <strong>Render Error:</strong> ${escapeHtml(message)}
682
+ </div>`;
683
+ }
684
+ createDebugBlock(token) {
685
+ if (this.config.format === "html") {
686
+ return `<div style="background-color: #fffbf0; border: 1px solid #fed; color: #b8860b; padding: 8px; border-radius: 4px; margin: 8px 0; font-size: 14px;">
687
+ <strong>Unknown token type:</strong> ${escapeHtml(token.type)}<br>
688
+ <strong>Content:</strong> ${escapeHtml(token.content || token.raw || "")}
689
+ </div>`;
690
+ }
691
+ return `<div class="bg-yellow-100 border border-yellow-300 text-yellow-800 p-2 rounded text-sm mb-2">
692
+ <strong>Unknown token type:</strong> ${escapeHtml(token.type)}<br>
693
+ <strong>Content:</strong> ${escapeHtml(token.content || token.raw || "")}
694
+ </div>`;
695
+ }
696
+ setupDefaultRules() {
697
+ this.addRule({
698
+ type: "heading",
699
+ render: (token) => {
700
+ const level = parseInt(token.attributes?.level || "1");
701
+ const text = token.content;
702
+ const id = generateId(text);
703
+ const escapedContent = escapeHtml(text);
704
+ if (this.config.format === "html") {
705
+ return `<h${level} id="${id}">${escapedContent}</h${level}>`;
706
+ }
707
+ let headingClasses = "group relative flex items-center gap-2";
708
+ switch (level) {
709
+ case 1:
710
+ headingClasses += " text-3xl font-bold mt-8 mb-4";
711
+ break;
712
+ case 2:
713
+ headingClasses += " text-2xl font-semibold mt-6 mb-3";
714
+ break;
715
+ case 3:
716
+ headingClasses += " text-xl font-medium mt-5 mb-3";
717
+ break;
718
+ case 4:
719
+ headingClasses += " text-lg font-medium mt-4 mb-2";
720
+ break;
721
+ case 5:
722
+ headingClasses += " text-base font-medium mt-3 mb-2";
723
+ break;
724
+ case 6:
725
+ headingClasses += " text-sm font-medium mt-3 mb-2";
726
+ break;
727
+ }
728
+ return `<h${level} id="${id}" class="${headingClasses}">
729
+ ${escapedContent}
730
+ <a href="#${id}" class="opacity-0 group-hover:opacity-100 text-muted-foreground transition-opacity">
731
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
732
+ <path d="M7.5 4H5.75A3.75 3.75 0 002 7.75v.5a3.75 3.75 0 003.75 3.75h1.5m-1.5-4h3m1.5-4h1.75A3.75 3.75 0 0114 7.75v.5a3.75 3.75 0 01-3.75 3.75H8.5"/>
733
+ </svg>
734
+ </a>
735
+ </h${level}>`;
736
+ }
737
+ });
738
+ this.addRule({
739
+ type: "bold",
740
+ render: (token) => {
741
+ const content = escapeHtml(token.content);
742
+ if (this.config.format === "html") {
743
+ return `<strong>${content}</strong>`;
744
+ }
745
+ return `<strong class="font-bold">${content}</strong>`;
746
+ }
747
+ });
748
+ this.addRule({
749
+ type: "italic",
750
+ render: (token) => {
751
+ const content = escapeHtml(token.content);
752
+ if (this.config.format === "html") {
753
+ return `<em>${content}</em>`;
754
+ }
755
+ return `<em class="italic">${content}</em>`;
756
+ }
757
+ });
758
+ this.addRule({
759
+ type: "code",
760
+ render: (token) => {
761
+ const content = escapeHtml(token.content);
762
+ if (this.config.format === "html") {
763
+ return `<code style="background-color: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 0.875rem;">${content}</code>`;
764
+ }
765
+ return `<code class="bg-muted px-1.5 py-0.5 rounded text-sm font-mono">${content}</code>`;
766
+ }
767
+ });
768
+ this.addRule({
769
+ type: "codeblock",
770
+ render: (token) => {
771
+ const language = token.attributes?.language || "text";
772
+ const escapedCode = escapeHtml(token.content);
773
+ if (this.config.format === "html") {
774
+ return `<pre style="background-color: #f3f4f6; padding: 16px; border-radius: 6px; overflow-x: auto; margin: 16px 0;"><code class="language-${escapeHtml(language)}">${escapedCode}</code></pre>`;
775
+ }
776
+ return `<pre class="bg-muted p-4 rounded-md overflow-x-auto my-4"><code class="language-${escapeHtml(language)}">${escapedCode}</code></pre>`;
777
+ }
778
+ });
779
+ this.addRule({
780
+ type: "link",
781
+ render: (token) => {
782
+ const href = token.attributes?.href || "#";
783
+ const escapedHref = escapeHtml(href);
784
+ const escapedText = escapeHtml(token.content);
785
+ if (this.config.format === "html") {
786
+ return `<a href="${escapedHref}" target="_blank" rel="noopener noreferrer">${escapedText}</a>`;
787
+ }
788
+ return `<a href="${escapedHref}" class="text-primary hover:underline inline-flex items-center gap-1" target="_blank" rel="noopener noreferrer">
789
+ ${escapedText}
790
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link">
791
+ <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
792
+ <polyline points="15 3 21 3 21 9"></polyline>
793
+ <line x1="10" y1="14" x2="21" y2="3"></line>
794
+ </svg>
795
+ </a>`;
796
+ }
797
+ });
798
+ this.addRule({
799
+ type: "list-item",
800
+ render: (token) => `<li>${escapeHtml(token.content)}</li>`
801
+ });
802
+ this.addRule({
803
+ type: "blockquote",
804
+ render: (token) => {
805
+ const content = escapeHtml(token.content);
806
+ if (this.config.format === "html") {
807
+ return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
808
+ }
809
+ return `<blockquote class="pl-4 py-2 border-l-2 border-border italic text-muted-foreground my-4">${content}</blockquote>`;
810
+ }
811
+ });
812
+ this.addRule({
813
+ type: "text",
814
+ render: (token) => {
815
+ if (!token.content) return "";
816
+ return escapeHtml(token.content);
817
+ }
818
+ });
819
+ this.addRule({
820
+ type: "paragraph",
821
+ render: (token) => {
822
+ if (!token.content) return "";
823
+ const content = token.content.trim();
824
+ if (!content) return "";
825
+ const processedContent = content.includes("<br>") ? content : escapeHtml(content);
826
+ if (this.config.format === "html") {
827
+ return `<p style="line-height: 1.75; margin-bottom: 16px;">${processedContent}</p>`;
828
+ }
829
+ return `<p class="leading-7 mb-4">${processedContent}</p>`;
830
+ }
831
+ });
832
+ this.addRule({
833
+ type: "task-item",
834
+ render: (token) => {
835
+ const isChecked = token.attributes?.checked === "true";
836
+ const escapedContent = escapeHtml(token.content);
837
+ if (this.config.format === "html") {
838
+ return `<div style="display: flex; align-items: center; gap: 8px; margin: 8px 0;">
839
+ <input type="checkbox" ${isChecked ? "checked" : ""} disabled style="margin: 0;" />
840
+ <span${isChecked ? ' style="text-decoration: line-through; color: #6b7280;"' : ""}>${escapedContent}</span>
841
+ </div>`;
842
+ }
843
+ return `<div class="flex items-center gap-2 my-2 task-list-item">
844
+ <input type="checkbox" ${isChecked ? "checked" : ""} disabled
845
+ class="form-checkbox h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary" />
846
+ <span${isChecked ? ' class="line-through text-muted-foreground"' : ""}>${escapedContent}</span>
847
+ </div>`;
848
+ }
849
+ });
850
+ this.addRule({
851
+ type: "image",
852
+ render: (token) => {
853
+ const src = token.attributes?.src || "";
854
+ const alt = token.attributes?.alt || "";
855
+ const title = token.attributes?.title || "";
856
+ const titleAttr = title ? ` title="${escapeHtml(title)}"` : "";
857
+ if (this.config.format === "html") {
858
+ return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"${titleAttr} style="max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0;" loading="lazy" />`;
859
+ }
860
+ return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"${titleAttr} class="max-w-full h-auto rounded-lg my-4" loading="lazy" />`;
861
+ }
862
+ });
863
+ this.addRule({
864
+ type: "hr",
865
+ render: () => {
866
+ if (this.config.format === "html") {
867
+ return '<hr style="margin: 24px 0; border: none; border-top: 1px solid #d1d5db;">';
868
+ }
869
+ return '<hr class="my-6 border-t border-border">';
870
+ }
871
+ });
872
+ this.addRule({
873
+ type: "line-break",
874
+ render: () => "<br>"
875
+ });
876
+ this.addRule({
877
+ type: "paragraph-break",
878
+ render: () => "</p><p>"
879
+ });
880
+ this.addRule({
881
+ type: "soft-break",
882
+ render: (token) => token.content || " "
883
+ });
884
+ }
885
+ };
886
+
887
+ // src/extensions/alert.ts
888
+ var AlertExtension = {
889
+ name: "alert",
890
+ parseRules: [
891
+ {
892
+ name: "alert",
893
+ pattern: /:::(\w+)(?:\s+(.*?))?\s*\n([\s\S]*?)\n:::/,
894
+ render: (match) => {
895
+ return {
896
+ type: "alert",
897
+ content: match[3]?.trim() || "",
898
+ raw: match[0] || "",
899
+ attributes: {
900
+ type: match[1] || "info",
901
+ title: match[2] || ""
902
+ }
903
+ };
904
+ }
905
+ }
906
+ ],
907
+ renderRules: [
908
+ {
909
+ type: "alert",
910
+ render: (token) => {
911
+ const type = token.attributes?.type || "info";
912
+ const title = token.attributes?.title || "";
913
+ const typeConfig = {
914
+ info: {
915
+ icon: "\u2139\uFE0F",
916
+ classes: "bg-blue-500/10 border-blue-500/30 text-blue-600 border-l-blue-500"
917
+ },
918
+ warning: {
919
+ icon: "\u26A0\uFE0F",
920
+ classes: "bg-amber-500/10 border-amber-500/30 text-amber-600 border-l-amber-500"
921
+ },
922
+ error: {
923
+ icon: "\u274C",
924
+ classes: "bg-red-500/10 border-red-500/30 text-red-600 border-l-red-500"
925
+ },
926
+ success: {
927
+ icon: "\u2705",
928
+ classes: "bg-green-500/10 border-green-500/30 text-green-600 border-l-green-500"
929
+ },
930
+ tip: {
931
+ icon: "\u{1F4A1}",
932
+ classes: "bg-purple-500/10 border-purple-500/30 text-purple-600 border-l-purple-500"
933
+ },
934
+ note: {
935
+ icon: "\u{1F4DD}",
936
+ classes: "bg-gray-500/10 border-gray-500/30 text-gray-600 border-l-gray-500"
937
+ }
938
+ };
939
+ const config = typeConfig[type] || typeConfig.info;
940
+ const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
941
+ const classes = `${baseClasses} ${config?.classes}`;
942
+ const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
943
+ <span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
944
+ <span>${title}</span>
945
+ </div>` : `<div class="font-medium mb-2 flex items-center gap-2">
946
+ <span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
947
+ <span>${type.charAt(0).toUpperCase() + type.slice(1)}</span>
948
+ </div>`;
949
+ return `<div class="${classes}" role="alert" aria-live="polite">
950
+ ${titleHtml}
951
+ <div class="leading-relaxed">${token.content}</div>
952
+ </div>`;
953
+ }
954
+ }
955
+ ]
956
+ };
957
+
958
+ // src/extensions/button.ts
959
+ var ButtonExtension = {
960
+ name: "button",
961
+ parseRules: [
962
+ {
963
+ name: "button",
964
+ pattern: /\[button:([^\]]+)\]\(([^)]+)\)(?:\{([^}]+)\})?/,
965
+ render: (match) => {
966
+ const text = match[1] || "";
967
+ const href = match[2] || "";
968
+ const optionsString = match[3] || "";
969
+ const options = optionsString.split(",").map((opt) => opt.trim()).filter(Boolean);
970
+ const styleOptions = ["default", "primary", "secondary", "success", "danger", "outline", "ghost"];
971
+ const style = options.find((opt) => styleOptions.includes(opt)) || "primary";
972
+ const sizeOptions = ["sm", "md", "lg"];
973
+ const size = options.find((opt) => sizeOptions.includes(opt)) || "md";
974
+ const disabled = options.includes("disabled");
975
+ const target = options.includes("self") ? "_self" : "_blank";
976
+ return {
977
+ type: "button",
978
+ content: text,
979
+ raw: match[0] || "",
980
+ attributes: {
981
+ href,
982
+ style,
983
+ size,
984
+ disabled: disabled.toString(),
985
+ target
986
+ }
987
+ };
988
+ }
989
+ }
990
+ ],
991
+ renderRules: [
992
+ {
993
+ type: "button",
994
+ render: (token) => {
995
+ const href = token.attributes?.href || "#";
996
+ const style = token.attributes?.style || "primary";
997
+ const size = token.attributes?.size || "md";
998
+ const disabled = token.attributes?.disabled === "true";
999
+ const target = token.attributes?.target || "_blank";
1000
+ const text = token.content;
1001
+ const classes = buildButtonClasses(style, size);
1002
+ const targetAttr = target === "_blank" ? ' target="_blank" rel="noopener noreferrer"' : target === "_self" ? ' target="_self"' : "";
1003
+ const disabledAttr = disabled ? ' aria-disabled="true" tabindex="-1"' : "";
1004
+ const externalIcon = target === "_blank" && !disabled ? '<svg class="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/></svg>' : "";
1005
+ return `<a href="${href}" class="${classes}"${targetAttr}${disabledAttr}>
1006
+ ${text}${externalIcon}
1007
+ </a>`;
1008
+ }
1009
+ }
1010
+ ]
1011
+ };
1012
+ function buildButtonClasses(style, size) {
1013
+ const base = [
1014
+ "inline-flex",
1015
+ "items-center",
1016
+ "justify-center",
1017
+ "font-medium",
1018
+ "rounded-lg",
1019
+ "transition-colors",
1020
+ "focus:outline-none",
1021
+ "focus:ring-2",
1022
+ "focus:ring-offset-2",
1023
+ "disabled:opacity-50",
1024
+ "disabled:cursor-not-allowed"
1025
+ ];
1026
+ const sizes = {
1027
+ sm: ["px-3", "py-1.5", "text-sm"],
1028
+ md: ["px-4", "py-2", "text-base"],
1029
+ lg: ["px-6", "py-3", "text-lg"]
1030
+ };
1031
+ const styles = {
1032
+ default: ["bg-slate-600", "text-white", "hover:bg-slate-700", "focus:ring-slate-500"],
1033
+ primary: ["bg-blue-600", "text-white", "hover:bg-blue-700", "focus:ring-blue-500"],
1034
+ secondary: ["bg-gray-600", "text-white", "hover:bg-gray-700", "focus:ring-gray-500"],
1035
+ success: ["bg-green-600", "text-white", "hover:bg-green-700", "focus:ring-green-500"],
1036
+ danger: ["bg-red-600", "text-white", "hover:bg-red-700", "focus:ring-red-500"],
1037
+ outline: ["border", "border-blue-600", "text-blue-600", "hover:bg-blue-50", "focus:ring-blue-500"],
1038
+ ghost: ["text-gray-700", "hover:bg-gray-100", "focus:ring-gray-500"]
1039
+ };
1040
+ const allClasses = [
1041
+ ...base,
1042
+ ...sizes[size] ?? sizes.md ?? [],
1043
+ ...styles[style] ?? styles.primary ?? []
1044
+ ];
1045
+ return allClasses.join(" ");
1046
+ }
1047
+
1048
+ // src/extensions/embed.ts
1049
+ var EmbedExtension = {
1050
+ name: "embed",
1051
+ parseRules: [
1052
+ {
1053
+ name: "embed",
1054
+ pattern: /\[embed:(\w+)\]\(([^)]+)\)(?:\{([^}]+)\})?/,
1055
+ render: (match) => {
1056
+ return {
1057
+ type: "embed",
1058
+ content: match[2] || "",
1059
+ // URL
1060
+ raw: match[0] || "",
1061
+ attributes: {
1062
+ provider: match[1] || "generic",
1063
+ url: match[2] || "",
1064
+ options: match[3] || ""
1065
+ }
1066
+ };
1067
+ }
1068
+ }
1069
+ ],
1070
+ renderRules: [
1071
+ {
1072
+ type: "embed",
1073
+ render: (token) => {
1074
+ const provider = token.attributes?.provider || "generic";
1075
+ const url = token.attributes?.url || "";
1076
+ const options = token.attributes?.options || "";
1077
+ return renderEmbed(provider, url, options);
1078
+ }
1079
+ }
1080
+ ]
1081
+ };
1082
+ function renderEmbed(provider, url, options) {
1083
+ const baseClasses = "rounded-lg border bg-card text-card-foreground shadow-sm mb-6 overflow-hidden";
1084
+ const parsedOptions = parseOptions(options);
1085
+ switch (provider.toLowerCase()) {
1086
+ case "youtube":
1087
+ return renderYouTubeEmbed(url, parsedOptions, baseClasses);
1088
+ case "codepen":
1089
+ return renderCodePenEmbed(url, parsedOptions, baseClasses);
1090
+ case "figma":
1091
+ return renderFigmaEmbed(url, parsedOptions, baseClasses);
1092
+ case "twitter":
1093
+ case "tweet":
1094
+ return renderTwitterEmbed(url, parsedOptions, baseClasses);
1095
+ case "github":
1096
+ return renderGitHubEmbed(url, parsedOptions, baseClasses);
1097
+ case "vimeo":
1098
+ return renderVimeoEmbed(url, parsedOptions, baseClasses);
1099
+ case "spotify":
1100
+ return renderSpotifyEmbed(url, parsedOptions, baseClasses);
1101
+ case "codesandbox":
1102
+ return renderCodeSandboxEmbed(url, parsedOptions, baseClasses);
1103
+ default:
1104
+ return renderGenericEmbed(url, parsedOptions, baseClasses);
1105
+ }
1106
+ }
1107
+ function renderYouTubeEmbed(url, options, classes) {
1108
+ const videoId = extractYouTubeId(url);
1109
+ if (!videoId) {
1110
+ return createErrorEmbed("Invalid YouTube URL", url, classes);
1111
+ }
1112
+ const params = new URLSearchParams();
1113
+ if (options.autoplay === "1") params.set("autoplay", "1");
1114
+ if (options.mute === "1") params.set("mute", "1");
1115
+ if (options.loop === "1") {
1116
+ params.set("loop", "1");
1117
+ params.set("playlist", videoId);
1118
+ }
1119
+ if (options.controls === "0") params.set("controls", "0");
1120
+ if (options.start) params.set("start", options.start);
1121
+ params.set("rel", "0");
1122
+ params.set("modestbranding", "1");
1123
+ const embedUrl = `https://www.youtube.com/embed/${videoId}?${params.toString()}`;
1124
+ return `
1125
+ <div class="${classes}">
1126
+ <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
1127
+ <iframe
1128
+ style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;"
1129
+ src="${embedUrl}"
1130
+ title="YouTube video player"
1131
+ frameborder="0"
1132
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
1133
+ allowfullscreen>
1134
+ </iframe>
1135
+ </div>
1136
+ </div>`;
1137
+ }
1138
+ function renderCodePenEmbed(url, options, classes) {
1139
+ const match = url.match(/codepen\.io\/([^\/]+)\/(?:pen|embed)\/([^\/\?#]+)/);
1140
+ if (!match) {
1141
+ return createErrorEmbed("Invalid CodePen URL", url, classes);
1142
+ }
1143
+ const [, user, penId] = match;
1144
+ const height = options.height || "400";
1145
+ const theme = options.theme === "light" ? "light" : "dark";
1146
+ const defaultTab = options.tab || "result";
1147
+ const embedParams = new URLSearchParams({
1148
+ "default-tab": defaultTab,
1149
+ "theme-id": theme,
1150
+ "editable": "true"
1151
+ });
1152
+ const embedUrl = `https://codepen.io/${user}/embed/${penId}?${embedParams.toString()}`;
1153
+ return `
1154
+ <div class="${classes}">
1155
+ <iframe
1156
+ height="${height}"
1157
+ style="width: 100%; border: 0;"
1158
+ scrolling="no"
1159
+ title="CodePen Embed - ${penId}"
1160
+ src="${embedUrl}"
1161
+ frameborder="0"
1162
+ loading="lazy"
1163
+ allowtransparency="true"
1164
+ allowfullscreen="true">
1165
+ </iframe>
1166
+ </div>`;
1167
+ }
1168
+ function renderVimeoEmbed(url, options, classes) {
1169
+ const videoId = extractVimeoId(url);
1170
+ if (!videoId) {
1171
+ return createErrorEmbed("Invalid Vimeo URL", url, classes);
1172
+ }
1173
+ const params = new URLSearchParams();
1174
+ if (options.autoplay === "1") params.set("autoplay", "1");
1175
+ if (options.mute === "1") params.set("muted", "1");
1176
+ if (options.loop === "1") params.set("loop", "1");
1177
+ const embedUrl = `https://player.vimeo.com/video/${videoId}?${params.toString()}`;
1178
+ return `
1179
+ <div class="${classes}">
1180
+ <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
1181
+ <iframe
1182
+ style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;"
1183
+ src="${embedUrl}"
1184
+ title="Vimeo video player"
1185
+ frameborder="0"
1186
+ allow="autoplay; fullscreen; picture-in-picture"
1187
+ allowfullscreen>
1188
+ </iframe>
1189
+ </div>
1190
+ </div>`;
1191
+ }
1192
+ function renderSpotifyEmbed(url, options, classes) {
1193
+ const embedUrl = url.replace("open.spotify.com", "open.spotify.com/embed");
1194
+ const height = options.height || "380";
1195
+ return `
1196
+ <div class="${classes}">
1197
+ <iframe
1198
+ style="border-radius: 12px;"
1199
+ src="${embedUrl}"
1200
+ width="100%"
1201
+ height="${height}"
1202
+ frameborder="0"
1203
+ allowfullscreen=""
1204
+ allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
1205
+ loading="lazy">
1206
+ </iframe>
1207
+ </div>`;
1208
+ }
1209
+ function renderCodeSandboxEmbed(url, options, classes) {
1210
+ let embedUrl = url;
1211
+ if (url.includes("/s/")) {
1212
+ embedUrl = url.replace("/s/", "/embed/");
1213
+ }
1214
+ const height = options.height || "500";
1215
+ const view = options.view || "preview";
1216
+ if (!embedUrl.includes("?")) {
1217
+ embedUrl += `?view=${view}`;
1218
+ }
1219
+ return `
1220
+ <div class="${classes}">
1221
+ <iframe
1222
+ src="${embedUrl}"
1223
+ style="width: 100%; height: ${height}px; border: 0; border-radius: 4px; overflow: hidden;"
1224
+ title="CodeSandbox Embed"
1225
+ allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
1226
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts">
1227
+ </iframe>
1228
+ </div>`;
1229
+ }
1230
+ function renderFigmaEmbed(url, options, classes) {
1231
+ const embedUrl = `https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(url)}`;
1232
+ const height = options.height || "450";
1233
+ return `
1234
+ <div class="${classes}">
1235
+ <iframe
1236
+ style="border: none;"
1237
+ width="100%"
1238
+ height="${height}"
1239
+ src="${embedUrl}"
1240
+ allowfullscreen>
1241
+ </iframe>
1242
+ </div>`;
1243
+ }
1244
+ function renderTwitterEmbed(url, _options, classes) {
1245
+ return `
1246
+ <div class="${classes}">
1247
+ <div class="p-4">
1248
+ <div class="flex items-center gap-3 mb-3">
1249
+ <svg class="w-6 h-6 fill-current text-blue-500" viewBox="0 0 24 24">
1250
+ <path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/>
1251
+ </svg>
1252
+ <div>
1253
+ <div class="font-semibold text-foreground">Twitter Post</div>
1254
+ <div class="text-sm text-muted-foreground">External Link</div>
1255
+ </div>
1256
+ </div>
1257
+ <a href="${url}" target="_blank"
1258
+ class="inline-flex items-center gap-2 text-primary hover:text-primary/80 font-medium transition-colors">
1259
+ View on Twitter
1260
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1261
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
1262
+ </svg>
1263
+ </a>
1264
+ </div>
1265
+ </div>`;
1266
+ }
1267
+ function renderGitHubEmbed(url, _options, classes) {
1268
+ const parts = url.replace("https://github.com/", "").split("/");
1269
+ const owner = parts[0];
1270
+ const repo = parts[1];
1271
+ if (!owner || !repo) {
1272
+ return createErrorEmbed("Invalid GitHub URL", url, classes);
1273
+ }
1274
+ return `
1275
+ <div class="${classes}">
1276
+ <div class="p-4">
1277
+ <div class="flex items-center gap-3 mb-3">
1278
+ <svg class="w-6 h-6 fill-current" viewBox="0 0 24 24">
1279
+ <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
1280
+ </svg>
1281
+ <div>
1282
+ <div class="font-semibold text-foreground text-lg">${owner}/${repo}</div>
1283
+ <div class="text-sm text-muted-foreground">GitHub Repository</div>
1284
+ </div>
1285
+ </div>
1286
+ <a href="${url}" target="_blank"
1287
+ class="inline-flex items-center gap-2 text-primary hover:text-primary/80 font-medium transition-colors">
1288
+ View on GitHub
1289
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1290
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
1291
+ </svg>
1292
+ </a>
1293
+ </div>
1294
+ </div>`;
1295
+ }
1296
+ function renderGenericEmbed(url, _options, classes) {
1297
+ const domain = extractDomain(url);
1298
+ return `
1299
+ <div class="${classes}">
1300
+ <div class="p-4">
1301
+ <div class="flex items-center gap-3 mb-3">
1302
+ <div class="w-10 h-10 rounded-lg bg-muted flex items-center justify-center">
1303
+ <svg class="w-5 h-5 text-muted-foreground" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1304
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
1305
+ </svg>
1306
+ </div>
1307
+ <div>
1308
+ <div class="font-semibold text-foreground">External Link</div>
1309
+ <div class="text-sm text-muted-foreground">${domain}</div>
1310
+ </div>
1311
+ </div>
1312
+ <a href="${url}" target="_blank"
1313
+ class="inline-flex items-center gap-2 text-primary hover:text-primary/80 font-medium transition-colors break-all">
1314
+ ${url}
1315
+ <svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1316
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
1317
+ </svg>
1318
+ </a>
1319
+ </div>
1320
+ </div>`;
1321
+ }
1322
+ function createErrorEmbed(error, url, classes) {
1323
+ return `
1324
+ <div class="${classes}">
1325
+ <div class="p-4 text-destructive">
1326
+ <div class="font-medium flex items-center gap-2">
1327
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1328
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
1329
+ </svg>
1330
+ ${error}
1331
+ </div>
1332
+ <div class="text-sm text-muted-foreground mt-1 break-all">${url}</div>
1333
+ </div>
1334
+ </div>`;
1335
+ }
1336
+ function extractYouTubeId(url) {
1337
+ const patterns = [
1338
+ /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/|youtube\.com\/shorts\/)([^&\n?#]+)/,
1339
+ /youtube\.com\/watch\?.*v=([^&\n?#]+)/
1340
+ ];
1341
+ for (const pattern of patterns) {
1342
+ const match = url.match(pattern);
1343
+ if (match) return match[1] || null;
1344
+ }
1345
+ return null;
1346
+ }
1347
+ function extractVimeoId(url) {
1348
+ const match = url.match(/vimeo\.com\/(?:.*\/)?(\d+)/);
1349
+ return match?.[1] ?? null;
1350
+ }
1351
+
1352
+ // src/engine.ts
1353
+ var ChangerawrMarkdown = class {
1354
+ constructor(config) {
1355
+ this.extensions = /* @__PURE__ */ new Map();
1356
+ this.parser = new MarkdownParser(config?.parser);
1357
+ this.renderer = new MarkdownRenderer(config?.renderer);
1358
+ this.registerBuiltInExtensions();
1359
+ if (config?.extensions) {
1360
+ config.extensions.forEach((extension) => {
1361
+ this.registerExtension(extension);
1362
+ });
1363
+ }
1364
+ this.parser.setupDefaultRulesIfEmpty();
1365
+ }
1366
+ /**
1367
+ * Register a custom extension
1368
+ */
1369
+ registerExtension(extension) {
1370
+ try {
1371
+ this.extensions.set(extension.name, extension);
1372
+ extension.parseRules.forEach((rule) => {
1373
+ this.parser.addRule(rule);
1374
+ });
1375
+ extension.renderRules.forEach((rule) => {
1376
+ this.renderer.addRule(rule);
1377
+ });
1378
+ return {
1379
+ success: true,
1380
+ extensionName: extension.name
1381
+ };
1382
+ } catch (error) {
1383
+ const errorMessage = error instanceof Error ? error.message : String(error);
1384
+ return {
1385
+ success: false,
1386
+ extensionName: extension.name,
1387
+ error: errorMessage
1388
+ };
1389
+ }
1390
+ }
1391
+ /**
1392
+ * Unregister an extension
1393
+ */
1394
+ unregisterExtension(name) {
1395
+ const extension = this.extensions.get(name);
1396
+ if (!extension) {
1397
+ return false;
1398
+ }
1399
+ try {
1400
+ this.extensions.delete(name);
1401
+ this.rebuildParserAndRenderer();
1402
+ return true;
1403
+ } catch {
1404
+ return false;
1405
+ }
1406
+ }
1407
+ /**
1408
+ * Parse markdown content into tokens
1409
+ */
1410
+ parse(markdown2) {
1411
+ return this.parser.parse(markdown2);
1412
+ }
1413
+ /**
1414
+ * Render tokens to HTML
1415
+ */
1416
+ render(tokens) {
1417
+ return this.renderer.render(tokens);
1418
+ }
1419
+ /**
1420
+ * Parse and render markdown to HTML in one step
1421
+ */
1422
+ toHtml(markdown2) {
1423
+ const tokens = this.parse(markdown2);
1424
+ return this.render(tokens);
1425
+ }
1426
+ /**
1427
+ * Get list of registered extensions
1428
+ */
1429
+ getExtensions() {
1430
+ return Array.from(this.extensions.keys());
1431
+ }
1432
+ /**
1433
+ * Check if extension is registered
1434
+ */
1435
+ hasExtension(name) {
1436
+ return this.extensions.has(name);
1437
+ }
1438
+ /**
1439
+ * Get parser warnings
1440
+ */
1441
+ getWarnings() {
1442
+ return [...this.parser.getWarnings(), ...this.renderer.getWarnings()];
1443
+ }
1444
+ /**
1445
+ * Get debug information from last render
1446
+ */
1447
+ getDebugInfo() {
1448
+ return {
1449
+ warnings: this.getWarnings(),
1450
+ parseTime: 0,
1451
+ renderTime: 0,
1452
+ tokenCount: 0,
1453
+ iterationCount: 0
1454
+ };
1455
+ }
1456
+ /**
1457
+ * Get performance metrics for the last operation
1458
+ */
1459
+ getPerformanceMetrics() {
1460
+ return {
1461
+ parseTime: 0,
1462
+ renderTime: 0,
1463
+ totalTime: 0,
1464
+ tokenCount: 0
1465
+ };
1466
+ }
1467
+ /**
1468
+ * Register built-in extensions
1469
+ */
1470
+ registerBuiltInExtensions() {
1471
+ this.registerExtension(AlertExtension);
1472
+ this.registerExtension(ButtonExtension);
1473
+ this.registerExtension(EmbedExtension);
1474
+ }
1475
+ /**
1476
+ * Rebuild parser and renderer with current extensions
1477
+ */
1478
+ rebuildParserAndRenderer() {
1479
+ const parserConfig = this.parser.getConfig();
1480
+ const rendererConfig = this.renderer.getConfig();
1481
+ this.parser = new MarkdownParser(parserConfig);
1482
+ this.renderer = new MarkdownRenderer(rendererConfig);
1483
+ const extensionsToRegister = Array.from(this.extensions.values());
1484
+ this.extensions.clear();
1485
+ extensionsToRegister.forEach((extension) => {
1486
+ this.registerExtension(extension);
1487
+ });
1488
+ this.parser.setupDefaultRulesIfEmpty();
1489
+ }
1490
+ };
1491
+ var markdown = new ChangerawrMarkdown();
1492
+
1493
+ // src/react/hooks.ts
1494
+ function useMarkdown(initialContent = "", options = {}) {
1495
+ const [content, setContent] = (0, import_react.useState)(initialContent);
1496
+ const [html, setHtml] = (0, import_react.useState)("");
1497
+ const [tokens, setTokens] = (0, import_react.useState)([]);
1498
+ const [isLoading, setIsLoading] = (0, import_react.useState)(false);
1499
+ const [error, setError] = (0, import_react.useState)(null);
1500
+ const [debug, setDebug] = (0, import_react.useState)(null);
1501
+ const engineRef = (0, import_react.useRef)(null);
1502
+ const engine = (0, import_react.useMemo)(() => {
1503
+ const format = options.format ?? "tailwind";
1504
+ const rendererConfig = {
1505
+ format,
1506
+ ...options.config?.renderer && {
1507
+ sanitize: options.config.renderer.sanitize,
1508
+ allowUnsafeHtml: options.config.renderer.allowUnsafeHtml,
1509
+ customClasses: options.config.renderer.customClasses,
1510
+ debugMode: options.debug ?? options.config.renderer.debugMode ?? false
1511
+ }
1512
+ };
1513
+ const engineConfig = {
1514
+ ...options.config && {
1515
+ parser: options.config.parser,
1516
+ extensions: options.config.extensions
1517
+ },
1518
+ renderer: rendererConfig
1519
+ };
1520
+ const newEngine = new ChangerawrMarkdown(engineConfig);
1521
+ if (options.extensions) {
1522
+ options.extensions.forEach((extension) => {
1523
+ newEngine.registerExtension(extension);
1524
+ });
1525
+ }
1526
+ engineRef.current = newEngine;
1527
+ return newEngine;
1528
+ }, [options.config, options.format, options.debug, options.extensions]);
1529
+ const processMarkdown = (0, import_react.useCallback)((markdownContent) => {
1530
+ if (!markdownContent.trim()) {
1531
+ setHtml("");
1532
+ setTokens([]);
1533
+ setError(null);
1534
+ setDebug(null);
1535
+ setIsLoading(false);
1536
+ return;
1537
+ }
1538
+ setIsLoading(true);
1539
+ setError(null);
1540
+ try {
1541
+ const parsedTokens = engine.parse(markdownContent);
1542
+ const renderedHtml = engine.render(parsedTokens);
1543
+ setHtml(renderedHtml);
1544
+ setTokens(parsedTokens);
1545
+ if (options.debug) {
1546
+ const coreDebug = engine.getDebugInfo();
1547
+ const performanceMetrics = engine.getPerformanceMetrics();
1548
+ setDebug({
1549
+ core: coreDebug,
1550
+ performance: performanceMetrics,
1551
+ renderedAt: /* @__PURE__ */ new Date(),
1552
+ contentLength: markdownContent.length,
1553
+ htmlLength: renderedHtml.length,
1554
+ extensionsUsed: engine.getExtensions()
1555
+ });
1556
+ }
1557
+ } catch (err) {
1558
+ const errorObj = err instanceof Error ? err : new Error(String(err));
1559
+ setError(errorObj);
1560
+ } finally {
1561
+ setIsLoading(false);
1562
+ }
1563
+ }, [engine, options.debug]);
1564
+ (0, import_react.useEffect)(() => {
1565
+ processMarkdown(content);
1566
+ }, [content, processMarkdown]);
1567
+ (0, import_react.useEffect)(() => {
1568
+ setContent(initialContent);
1569
+ }, [initialContent]);
1570
+ const render = (0, import_react.useCallback)((newContent) => {
1571
+ setContent(newContent);
1572
+ }, []);
1573
+ const clear = (0, import_react.useCallback)(() => {
1574
+ setContent("");
1575
+ setHtml("");
1576
+ setTokens([]);
1577
+ setError(null);
1578
+ setDebug(null);
1579
+ }, []);
1580
+ return {
1581
+ html,
1582
+ tokens,
1583
+ isLoading,
1584
+ error,
1585
+ debug,
1586
+ render,
1587
+ clear
1588
+ };
1589
+ }
1590
+ function useMarkdownEngine(options = {}) {
1591
+ const engineRef = (0, import_react.useRef)(null);
1592
+ const engine = (0, import_react.useMemo)(() => {
1593
+ const engineConfig = {
1594
+ ...options.config,
1595
+ renderer: {
1596
+ format: "tailwind",
1597
+ // Required field
1598
+ ...options.config?.renderer
1599
+ }
1600
+ };
1601
+ if (options.autoRegisterExtensions === false) {
1602
+ engineConfig.extensions = [];
1603
+ }
1604
+ const newEngine = new ChangerawrMarkdown(engineConfig);
1605
+ engineRef.current = newEngine;
1606
+ return newEngine;
1607
+ }, [options.config, options.autoRegisterExtensions]);
1608
+ const toHtml = (0, import_react.useCallback)((content) => {
1609
+ return engine.toHtml(content);
1610
+ }, [engine]);
1611
+ const parse = (0, import_react.useCallback)((content) => {
1612
+ return engine.parse(content);
1613
+ }, [engine]);
1614
+ const render = (0, import_react.useCallback)((tokens) => {
1615
+ return engine.render(tokens);
1616
+ }, [engine]);
1617
+ const getExtensions = (0, import_react.useCallback)(() => {
1618
+ return engine.getExtensions();
1619
+ }, [engine]);
1620
+ const hasExtension = (0, import_react.useCallback)((name) => {
1621
+ return engine.hasExtension(name);
1622
+ }, [engine]);
1623
+ const registerExtension = (0, import_react.useCallback)((extension) => {
1624
+ return engine.registerExtension(extension);
1625
+ }, [engine]);
1626
+ const unregisterExtension = (0, import_react.useCallback)((name) => {
1627
+ return engine.unregisterExtension(name);
1628
+ }, [engine]);
1629
+ const getWarnings = (0, import_react.useCallback)(() => {
1630
+ return engine.getWarnings();
1631
+ }, [engine]);
1632
+ const getDebugInfo = (0, import_react.useCallback)(() => {
1633
+ return engine.getDebugInfo();
1634
+ }, [engine]);
1635
+ const getPerformanceMetrics = (0, import_react.useCallback)(() => {
1636
+ return engine.getPerformanceMetrics();
1637
+ }, [engine]);
1638
+ return {
1639
+ engine,
1640
+ toHtml,
1641
+ parse,
1642
+ render,
1643
+ getExtensions,
1644
+ hasExtension,
1645
+ registerExtension,
1646
+ unregisterExtension,
1647
+ getWarnings,
1648
+ getDebugInfo,
1649
+ getPerformanceMetrics
1650
+ };
1651
+ }
1652
+ function useMarkdownDebug(content) {
1653
+ const { html, tokens, debug } = useMarkdown(content, { debug: true });
1654
+ return {
1655
+ html,
1656
+ tokens,
1657
+ debug,
1658
+ stats: {
1659
+ tokenCount: tokens.length,
1660
+ htmlLength: html.length,
1661
+ contentLength: content.length
1662
+ }
1663
+ };
1664
+ }
1665
+
1666
+ // src/react/MarkdownRenderer.tsx
1667
+ var import_jsx_runtime = require("react/jsx-runtime");
1668
+ function MarkdownRenderer2({
1669
+ content,
1670
+ className,
1671
+ config,
1672
+ format = "tailwind",
1673
+ as: Component = "div",
1674
+ wrapperProps = {},
1675
+ debug = false,
1676
+ errorFallback,
1677
+ loading,
1678
+ onRender,
1679
+ onError,
1680
+ extensions,
1681
+ sanitize = true,
1682
+ allowUnsafeHtml = false,
1683
+ ...restProps
1684
+ }) {
1685
+ const markdownOptions = (0, import_react2.useMemo)(() => {
1686
+ const options = {
1687
+ format,
1688
+ debug,
1689
+ debounceMs: 0,
1690
+ // No debounce for tests
1691
+ memoize: true
1692
+ };
1693
+ if (config) {
1694
+ options.config = {
1695
+ ...config,
1696
+ renderer: {
1697
+ format,
1698
+ // Required field
1699
+ sanitize,
1700
+ allowUnsafeHtml,
1701
+ debugMode: debug,
1702
+ ...config.renderer
1703
+ }
1704
+ };
1705
+ } else {
1706
+ options.config = {
1707
+ renderer: {
1708
+ format,
1709
+ sanitize,
1710
+ allowUnsafeHtml,
1711
+ debugMode: debug
1712
+ }
1713
+ };
1714
+ }
1715
+ if (extensions) {
1716
+ options.extensions = extensions;
1717
+ }
1718
+ return options;
1719
+ }, [config, format, debug, extensions, sanitize, allowUnsafeHtml]);
1720
+ const { html, tokens, isLoading, error } = useMarkdown(content, markdownOptions);
1721
+ (0, import_react2.useEffect)(() => {
1722
+ if (html && onRender) {
1723
+ onRender(html, tokens);
1724
+ }
1725
+ }, [html, tokens, onRender]);
1726
+ (0, import_react2.useEffect)(() => {
1727
+ if (error && onError) {
1728
+ onError(error);
1729
+ }
1730
+ }, [error, onError]);
1731
+ if (isLoading && loading) {
1732
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: loading });
1733
+ }
1734
+ if (error) {
1735
+ if (errorFallback) {
1736
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: errorFallback(error) });
1737
+ }
1738
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "changerawr-error bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded", children: [
1739
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "font-medium", children: "Markdown Render Error" }),
1740
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm mt-1", children: error.message })
1741
+ ] });
1742
+ }
1743
+ const finalWrapperProps = {
1744
+ ...wrapperProps,
1745
+ ...restProps,
1746
+ className: className ? `${className} changerawr-markdown` : "changerawr-markdown",
1747
+ dangerouslySetInnerHTML: { __html: html }
1748
+ };
1749
+ return import_react2.default.createElement(Component, finalWrapperProps);
1750
+ }
1751
+ MarkdownRenderer2.displayName = "MarkdownRenderer";
1752
+ var MarkdownErrorBoundary = class extends import_react2.default.Component {
1753
+ constructor(props) {
1754
+ super(props);
1755
+ this.state = { hasError: false, error: null };
1756
+ }
1757
+ static getDerivedStateFromError(error) {
1758
+ return { hasError: true, error };
1759
+ }
1760
+ componentDidCatch(error, errorInfo) {
1761
+ console.error("MarkdownRenderer Error:", error, errorInfo);
1762
+ }
1763
+ render() {
1764
+ if (this.state.hasError && this.state.error) {
1765
+ if (this.props.fallback) {
1766
+ return this.props.fallback(this.state.error);
1767
+ }
1768
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "changerawr-error-boundary bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded", children: [
1769
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "font-medium", children: "Markdown Component Error" }),
1770
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm mt-1", children: this.state.error.message }),
1771
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1772
+ "button",
1773
+ {
1774
+ onClick: () => this.setState({ hasError: false, error: null }),
1775
+ className: "text-xs mt-2 px-2 py-1 bg-red-200 hover:bg-red-300 rounded",
1776
+ children: "Try Again"
1777
+ }
1778
+ )
1779
+ ] });
1780
+ }
1781
+ return this.props.children;
1782
+ }
1783
+ };
1784
+ // Annotate the CommonJS export names for ESM import in node:
1785
+ 0 && (module.exports = {
1786
+ MarkdownRenderer,
1787
+ useMarkdown,
1788
+ useMarkdownDebug,
1789
+ useMarkdownEngine
1790
+ });
1791
+ //# sourceMappingURL=index.js.map