@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/index.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
|
|
@@ -540,7 +552,19 @@ var MarkdownRenderer = class {
|
|
|
540
552
|
const rule = this.rules.get(token.type);
|
|
541
553
|
if (rule) {
|
|
542
554
|
try {
|
|
543
|
-
|
|
555
|
+
let tokenToRender = token;
|
|
556
|
+
if (token.children && token.children.length > 0) {
|
|
557
|
+
const renderedChildren = this.render(token.children);
|
|
558
|
+
tokenToRender = {
|
|
559
|
+
...token,
|
|
560
|
+
attributes: {
|
|
561
|
+
...token.attributes,
|
|
562
|
+
renderedChildren
|
|
563
|
+
// Extensions can use this instead of re-parsing
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
return rule.render(tokenToRender);
|
|
544
568
|
} catch (error) {
|
|
545
569
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
546
570
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -609,8 +633,10 @@ var BlockquoteExtension = {
|
|
|
609
633
|
{
|
|
610
634
|
type: "blockquote",
|
|
611
635
|
render: (token) => {
|
|
612
|
-
const content = escapeHtml(token.content);
|
|
613
636
|
const format = token.attributes?.format || "html";
|
|
637
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
638
|
+
const renderMarkdown2 = token.attributes?.renderMarkdown;
|
|
639
|
+
const content = renderedChildren || (renderMarkdown2 ? renderMarkdown2(token.content) : escapeHtml(token.content));
|
|
614
640
|
if (format === "html") {
|
|
615
641
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
616
642
|
}
|
|
@@ -1115,6 +1141,9 @@ var AlertExtension = {
|
|
|
1115
1141
|
const config = typeConfig[type] || typeConfig.info;
|
|
1116
1142
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
1117
1143
|
const classes = `${baseClasses} ${config?.classes}`;
|
|
1144
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
1145
|
+
const renderMarkdown2 = token.attributes?.renderMarkdown;
|
|
1146
|
+
const renderedContent = renderedChildren || (renderMarkdown2 ? renderMarkdown2(token.content) : token.content);
|
|
1118
1147
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
1119
1148
|
<span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
|
|
1120
1149
|
<span>${title}</span>
|
|
@@ -1124,7 +1153,7 @@ var AlertExtension = {
|
|
|
1124
1153
|
</div>`;
|
|
1125
1154
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
1126
1155
|
${titleHtml}
|
|
1127
|
-
<div class="leading-relaxed">${
|
|
1156
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
1128
1157
|
</div>`;
|
|
1129
1158
|
}
|
|
1130
1159
|
}
|