@changerawr/markdown 1.1.3 → 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 +2 -2
|
@@ -1229,7 +1229,8 @@ var ChangerawrMarkdown = (() => {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
i = j;
|
|
1231
1231
|
} else if (token) {
|
|
1232
|
-
|
|
1232
|
+
const processedToken = this.recursivelyParseBlockContent(token);
|
|
1233
|
+
processed.push(processedToken);
|
|
1233
1234
|
i++;
|
|
1234
1235
|
} else {
|
|
1235
1236
|
i++;
|
|
@@ -1237,6 +1238,16 @@ var ChangerawrMarkdown = (() => {
|
|
|
1237
1238
|
}
|
|
1238
1239
|
return processed;
|
|
1239
1240
|
}
|
|
1241
|
+
recursivelyParseBlockContent(token) {
|
|
1242
|
+
const blockTypes = ["alert", "blockquote"];
|
|
1243
|
+
if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
|
|
1244
|
+
const children = this.parse(token.content);
|
|
1245
|
+
return __spreadProps(__spreadValues({}, token), {
|
|
1246
|
+
children
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
return token;
|
|
1250
|
+
}
|
|
1240
1251
|
};
|
|
1241
1252
|
|
|
1242
1253
|
// src/utils.ts
|
|
@@ -1499,7 +1510,17 @@ var ChangerawrMarkdown = (() => {
|
|
|
1499
1510
|
const rule = this.rules.get(token.type);
|
|
1500
1511
|
if (rule) {
|
|
1501
1512
|
try {
|
|
1502
|
-
|
|
1513
|
+
let tokenToRender = token;
|
|
1514
|
+
if (token.children && token.children.length > 0) {
|
|
1515
|
+
const renderedChildren = this.render(token.children);
|
|
1516
|
+
tokenToRender = __spreadProps(__spreadValues({}, token), {
|
|
1517
|
+
attributes: __spreadProps(__spreadValues({}, token.attributes), {
|
|
1518
|
+
renderedChildren
|
|
1519
|
+
// Extensions can use this instead of re-parsing
|
|
1520
|
+
})
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
return rule.render(tokenToRender);
|
|
1503
1524
|
} catch (error) {
|
|
1504
1525
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1505
1526
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -1568,9 +1589,11 @@ var ChangerawrMarkdown = (() => {
|
|
|
1568
1589
|
{
|
|
1569
1590
|
type: "blockquote",
|
|
1570
1591
|
render: (token) => {
|
|
1571
|
-
var _a;
|
|
1572
|
-
const content = escapeHtml(token.content);
|
|
1592
|
+
var _a, _b, _c;
|
|
1573
1593
|
const format = ((_a = token.attributes) == null ? void 0 : _a.format) || "html";
|
|
1594
|
+
const renderedChildren = (_b = token.attributes) == null ? void 0 : _b.renderedChildren;
|
|
1595
|
+
const renderMarkdown = (_c = token.attributes) == null ? void 0 : _c.renderMarkdown;
|
|
1596
|
+
const content = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : escapeHtml(token.content));
|
|
1574
1597
|
if (format === "html") {
|
|
1575
1598
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
1576
1599
|
}
|
|
@@ -2058,7 +2081,7 @@ var ChangerawrMarkdown = (() => {
|
|
|
2058
2081
|
{
|
|
2059
2082
|
type: "alert",
|
|
2060
2083
|
render: (token) => {
|
|
2061
|
-
var _a, _b;
|
|
2084
|
+
var _a, _b, _c, _d;
|
|
2062
2085
|
const type = ((_a = token.attributes) == null ? void 0 : _a.type) || "info";
|
|
2063
2086
|
const title = ((_b = token.attributes) == null ? void 0 : _b.title) || "";
|
|
2064
2087
|
const typeConfig = {
|
|
@@ -2090,6 +2113,9 @@ var ChangerawrMarkdown = (() => {
|
|
|
2090
2113
|
const config = typeConfig[type] || typeConfig.info;
|
|
2091
2114
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
2092
2115
|
const classes = `${baseClasses} ${config == null ? void 0 : config.classes}`;
|
|
2116
|
+
const renderedChildren = (_c = token.attributes) == null ? void 0 : _c.renderedChildren;
|
|
2117
|
+
const renderMarkdown = (_d = token.attributes) == null ? void 0 : _d.renderMarkdown;
|
|
2118
|
+
const renderedContent = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : token.content);
|
|
2093
2119
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
2094
2120
|
<span class="text-lg" role="img" aria-label="${type}">${config == null ? void 0 : config.icon}</span>
|
|
2095
2121
|
<span>${title}</span>
|
|
@@ -2099,7 +2125,7 @@ var ChangerawrMarkdown = (() => {
|
|
|
2099
2125
|
</div>`;
|
|
2100
2126
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
2101
2127
|
${titleHtml}
|
|
2102
|
-
<div class="leading-relaxed">${
|
|
2128
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
2103
2129
|
</div>`;
|
|
2104
2130
|
}
|
|
2105
2131
|
}
|
package/dist/standalone.d.mts
CHANGED
package/dist/standalone.d.ts
CHANGED
package/dist/standalone.js
CHANGED
|
@@ -230,7 +230,8 @@ var MarkdownParser = class {
|
|
|
230
230
|
}
|
|
231
231
|
i = j;
|
|
232
232
|
} else if (token) {
|
|
233
|
-
|
|
233
|
+
const processedToken = this.recursivelyParseBlockContent(token);
|
|
234
|
+
processed.push(processedToken);
|
|
234
235
|
i++;
|
|
235
236
|
} else {
|
|
236
237
|
i++;
|
|
@@ -238,6 +239,17 @@ var MarkdownParser = class {
|
|
|
238
239
|
}
|
|
239
240
|
return processed;
|
|
240
241
|
}
|
|
242
|
+
recursivelyParseBlockContent(token) {
|
|
243
|
+
const blockTypes = ["alert", "blockquote"];
|
|
244
|
+
if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
|
|
245
|
+
const children = this.parse(token.content);
|
|
246
|
+
return {
|
|
247
|
+
...token,
|
|
248
|
+
children
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return token;
|
|
252
|
+
}
|
|
241
253
|
};
|
|
242
254
|
|
|
243
255
|
// src/utils.ts
|
|
@@ -503,7 +515,19 @@ var MarkdownRenderer = class {
|
|
|
503
515
|
const rule = this.rules.get(token.type);
|
|
504
516
|
if (rule) {
|
|
505
517
|
try {
|
|
506
|
-
|
|
518
|
+
let tokenToRender = token;
|
|
519
|
+
if (token.children && token.children.length > 0) {
|
|
520
|
+
const renderedChildren = this.render(token.children);
|
|
521
|
+
tokenToRender = {
|
|
522
|
+
...token,
|
|
523
|
+
attributes: {
|
|
524
|
+
...token.attributes,
|
|
525
|
+
renderedChildren
|
|
526
|
+
// Extensions can use this instead of re-parsing
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
return rule.render(tokenToRender);
|
|
507
531
|
} catch (error) {
|
|
508
532
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
509
533
|
this.warnings.push(`Render error for ${token.type}: ${errorMessage}`);
|
|
@@ -572,8 +596,10 @@ var BlockquoteExtension = {
|
|
|
572
596
|
{
|
|
573
597
|
type: "blockquote",
|
|
574
598
|
render: (token) => {
|
|
575
|
-
const content = escapeHtml(token.content);
|
|
576
599
|
const format = token.attributes?.format || "html";
|
|
600
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
601
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
602
|
+
const content = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : escapeHtml(token.content));
|
|
577
603
|
if (format === "html") {
|
|
578
604
|
return `<blockquote style="border-left: 2px solid #d1d5db; padding: 8px 0 8px 16px; margin: 16px 0; font-style: italic; color: #6b7280;">${content}</blockquote>`;
|
|
579
605
|
}
|
|
@@ -1078,6 +1104,9 @@ var AlertExtension = {
|
|
|
1078
1104
|
const config = typeConfig[type] || typeConfig.info;
|
|
1079
1105
|
const baseClasses = "border-l-4 p-4 mb-4 rounded-md transition-colors duration-200";
|
|
1080
1106
|
const classes = `${baseClasses} ${config?.classes}`;
|
|
1107
|
+
const renderedChildren = token.attributes?.renderedChildren;
|
|
1108
|
+
const renderMarkdown = token.attributes?.renderMarkdown;
|
|
1109
|
+
const renderedContent = renderedChildren || (renderMarkdown ? renderMarkdown(token.content) : token.content);
|
|
1081
1110
|
const titleHtml = title ? `<div class="font-medium mb-2 flex items-center gap-2">
|
|
1082
1111
|
<span class="text-lg" role="img" aria-label="${type}">${config?.icon}</span>
|
|
1083
1112
|
<span>${title}</span>
|
|
@@ -1087,7 +1116,7 @@ var AlertExtension = {
|
|
|
1087
1116
|
</div>`;
|
|
1088
1117
|
return `<div class="${classes}" role="alert" aria-live="polite">
|
|
1089
1118
|
${titleHtml}
|
|
1090
|
-
<div class="leading-relaxed">${
|
|
1119
|
+
<div class="leading-relaxed">${renderedContent}</div>
|
|
1091
1120
|
</div>`;
|
|
1092
1121
|
}
|
|
1093
1122
|
}
|