@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.mjs
CHANGED
|
@@ -193,7 +193,8 @@ var MarkdownParser = class {
|
|
|
193
193
|
}
|
|
194
194
|
i = j;
|
|
195
195
|
} else if (token) {
|
|
196
|
-
|
|
196
|
+
const processedToken = this.recursivelyParseBlockContent(token);
|
|
197
|
+
processed.push(processedToken);
|
|
197
198
|
i++;
|
|
198
199
|
} else {
|
|
199
200
|
i++;
|
|
@@ -201,6 +202,17 @@ var MarkdownParser = class {
|
|
|
201
202
|
}
|
|
202
203
|
return processed;
|
|
203
204
|
}
|
|
205
|
+
recursivelyParseBlockContent(token) {
|
|
206
|
+
const blockTypes = ["alert", "blockquote"];
|
|
207
|
+
if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
|
|
208
|
+
const children = this.parse(token.content);
|
|
209
|
+
return {
|
|
210
|
+
...token,
|
|
211
|
+
children
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return token;
|
|
215
|
+
}
|
|
204
216
|
};
|
|
205
217
|
|
|
206
218
|
// src/utils.ts
|
|
@@ -466,7 +478,19 @@ var MarkdownRenderer = class {
|
|
|
466
478
|
const rule = this.rules.get(token.type);
|
|
467
479
|
if (rule) {
|
|
468
480
|
try {
|
|
469
|
-
|
|
481
|
+
let tokenToRender = token;
|
|
482
|
+
if (token.children && token.children.length > 0) {
|
|
483
|
+
const renderedChildren = this.render(token.children);
|
|
484
|
+
tokenToRender = {
|
|
485
|
+
...token,
|
|
486
|
+
attributes: {
|
|
487
|
+
...token.attributes,
|
|
488
|
+
renderedChildren
|
|
489
|
+
// Extensions can use this instead of re-parsing
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
return rule.render(tokenToRender);
|
|
470
494
|
} catch (error) {
|
|
471
495
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
472
496
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -535,8 +559,10 @@ var BlockquoteExtension = {
|
|
|
535
559
|
{
|
|
536
560
|
type: "blockquote",
|
|
537
561
|
render: (token) => {
|
|
538
|
-
const content = escapeHtml(token.content);
|
|
539
562
|
const format = token.attributes?.format || "html";
|
|
563
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
564
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
565
|
+
const content = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : escapeHtml(token.content));
|
|
540
566
|
if (format === "html") {
|
|
541
567
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
542
568
|
}
|
|
@@ -1041,6 +1067,9 @@ var AlertExtension = {
|
|
|
1041
1067
|
const config = typeConfig[type] || typeConfig.info;
|
|
1042
1068
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
1043
1069
|
const classes = `${baseClasses} ${config?.classes}`;
|
|
1070
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
1071
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
1072
|
+
const renderedContent = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : token.content);
|
|
1044
1073
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
1045
1074
|
<span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
|
|
1046
1075
|
<span>${title}</span>
|
|
@@ -1050,7 +1079,7 @@ var AlertExtension = {
|
|
|
1050
1079
|
</div>`;
|
|
1051
1080
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
1052
1081
|
${titleHtml}
|
|
1053
|
-
<div class="leading-relaxed">${
|
|
1082
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
1054
1083
|
</div>`;
|
|
1055
1084
|
}
|
|
1056
1085
|
}
|