@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/react/index.d.mts
CHANGED
package/dist/react/index.d.ts
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -232,7 +232,8 @@ var MarkdownParser = class {
|
|
|
232
232
|
}
|
|
233
233
|
i = j;
|
|
234
234
|
} else if (token) {
|
|
235
|
-
|
|
235
|
+
const processedToken = this.recursivelyParseBlockContent(token);
|
|
236
|
+
processed.push(processedToken);
|
|
236
237
|
i++;
|
|
237
238
|
} else {
|
|
238
239
|
i++;
|
|
@@ -240,6 +241,17 @@ var MarkdownParser = class {
|
|
|
240
241
|
}
|
|
241
242
|
return processed;
|
|
242
243
|
}
|
|
244
|
+
recursivelyParseBlockContent(token) {
|
|
245
|
+
const blockTypes = ["alert", "blockquote"];
|
|
246
|
+
if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
|
|
247
|
+
const children = this.parse(token.content);
|
|
248
|
+
return {
|
|
249
|
+
...token,
|
|
250
|
+
children
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
return token;
|
|
254
|
+
}
|
|
243
255
|
};
|
|
244
256
|
|
|
245
257
|
// src/utils.ts
|
|
@@ -505,7 +517,19 @@ var MarkdownRenderer = class {
|
|
|
505
517
|
const rule = this.rules.get(token.type);
|
|
506
518
|
if (rule) {
|
|
507
519
|
try {
|
|
508
|
-
|
|
520
|
+
let tokenToRender = token;
|
|
521
|
+
if (token.children && token.children.length > 0) {
|
|
522
|
+
const renderedChildren = this.render(token.children);
|
|
523
|
+
tokenToRender = {
|
|
524
|
+
...token,
|
|
525
|
+
attributes: {
|
|
526
|
+
...token.attributes,
|
|
527
|
+
renderedChildren
|
|
528
|
+
// Extensions can use this instead of re-parsing
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
return rule.render(tokenToRender);
|
|
509
533
|
} catch (error) {
|
|
510
534
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
511
535
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -574,8 +598,10 @@ var BlockquoteExtension = {
|
|
|
574
598
|
{
|
|
575
599
|
type: "blockquote",
|
|
576
600
|
render: (token) => {
|
|
577
|
-
const content = escapeHtml(token.content);
|
|
578
601
|
const format = token.attributes?.format || "html";
|
|
602
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
603
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
604
|
+
const content = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : escapeHtml(token.content));
|
|
579
605
|
if (format === "html") {
|
|
580
606
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
581
607
|
}
|
|
@@ -1080,6 +1106,9 @@ var AlertExtension = {
|
|
|
1080
1106
|
const config = typeConfig[type] || typeConfig.info;
|
|
1081
1107
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
1082
1108
|
const classes = `${baseClasses} ${config?.classes}`;
|
|
1109
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
1110
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
1111
|
+
const renderedContent = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : token.content);
|
|
1083
1112
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
1084
1113
|
<span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
|
|
1085
1114
|
<span>${title}</span>
|
|
@@ -1089,7 +1118,7 @@ var AlertExtension = {
|
|
|
1089
1118
|
</div>`;
|
|
1090
1119
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
1091
1120
|
${titleHtml}
|
|
1092
|
-
<div class="leading-relaxed">${
|
|
1121
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
1093
1122
|
</div>`;
|
|
1094
1123
|
}
|
|
1095
1124
|
}
|