@changerawr/markdown 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/index.css +123 -3
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +33 -4
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +33 -4
- package/dist/react/index.mjs.map +1 -1
- package/dist/standalone.browser.js +32 -6
- package/dist/standalone.d.mts +1 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/standalone.js +33 -4
- package/dist/standalone.js.map +1 -1
- package/dist/standalone.mjs +33 -4
- package/dist/standalone.mjs.map +1 -1
- package/dist/tailwind/index.d.mts +35 -4
- package/dist/tailwind/index.d.ts +35 -4
- package/dist/tailwind/index.js +185 -120
- package/dist/tailwind/index.js.map +1 -1
- package/dist/tailwind/index.mjs +183 -119
- package/dist/tailwind/index.mjs.map +1 -1
- package/package.json +5 -2
package/dist/standalone.mjs
CHANGED
|
@@ -187,7 +187,8 @@ var MarkdownParser = class {
|
|
|
187
187
|
}
|
|
188
188
|
i = j;
|
|
189
189
|
} else if (token) {
|
|
190
|
-
|
|
190
|
+
const processedToken = this.recursivelyParseBlockContent(token);
|
|
191
|
+
processed.push(processedToken);
|
|
191
192
|
i++;
|
|
192
193
|
} else {
|
|
193
194
|
i++;
|
|
@@ -195,6 +196,17 @@ var MarkdownParser = class {
|
|
|
195
196
|
}
|
|
196
197
|
return processed;
|
|
197
198
|
}
|
|
199
|
+
recursivelyParseBlockContent(token) {
|
|
200
|
+
const blockTypes = ["alert", "blockquote"];
|
|
201
|
+
if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
|
|
202
|
+
const children = this.parse(token.content);
|
|
203
|
+
return {
|
|
204
|
+
...token,
|
|
205
|
+
children
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return token;
|
|
209
|
+
}
|
|
198
210
|
};
|
|
199
211
|
|
|
200
212
|
// src/utils.ts
|
|
@@ -460,7 +472,19 @@ var MarkdownRenderer = class {
|
|
|
460
472
|
const rule = this.rules.get(token.type);
|
|
461
473
|
if (rule) {
|
|
462
474
|
try {
|
|
463
|
-
|
|
475
|
+
let tokenToRender = token;
|
|
476
|
+
if (token.children && token.children.length > 0) {
|
|
477
|
+
const renderedChildren = this.render(token.children);
|
|
478
|
+
tokenToRender = {
|
|
479
|
+
...token,
|
|
480
|
+
attributes: {
|
|
481
|
+
...token.attributes,
|
|
482
|
+
renderedChildren
|
|
483
|
+
// Extensions can use this instead of re-parsing
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
return rule.render(tokenToRender);
|
|
464
488
|
} catch (error) {
|
|
465
489
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
466
490
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -529,8 +553,10 @@ var BlockquoteExtension = {
|
|
|
529
553
|
{
|
|
530
554
|
type: "blockquote",
|
|
531
555
|
render: (token) => {
|
|
532
|
-
const content = escapeHtml(token.content);
|
|
533
556
|
const format = token.attributes?.format || "html";
|
|
557
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
558
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
559
|
+
const content = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : escapeHtml(token.content));
|
|
534
560
|
if (format === "html") {
|
|
535
561
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
536
562
|
}
|
|
@@ -1035,6 +1061,9 @@ var AlertExtension = {
|
|
|
1035
1061
|
const config = typeConfig[type] || typeConfig.info;
|
|
1036
1062
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
1037
1063
|
const classes = `${baseClasses} ${config?.classes}`;
|
|
1064
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
1065
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
1066
|
+
const renderedContent = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : token.content);
|
|
1038
1067
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
1039
1068
|
<span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
|
|
1040
1069
|
<span>${title}</span>
|
|
@@ -1044,7 +1073,7 @@ var AlertExtension = {
|
|
|
1044
1073
|
</div>`;
|
|
1045
1074
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
1046
1075
|
${titleHtml}
|
|
1047
|
-
<div class="leading-relaxed">${
|
|
1076
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
1048
1077
|
</div>`;
|
|
1049
1078
|
}
|
|
1050
1079
|
}
|