@changerawr/markdown 1.1.7 → 1.1.8
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +80 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -7
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +80 -7
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +80 -7
- package/dist/react/index.mjs.map +1 -1
- package/dist/standalone.browser.js +103 -19
- package/dist/standalone.js +80 -7
- package/dist/standalone.js.map +1 -1
- package/dist/standalone.mjs +80 -7
- package/dist/standalone.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -1005,7 +1005,8 @@ var ImageExtension = {
|
|
|
1005
1005
|
attributes: {
|
|
1006
1006
|
alt: match[1] || "",
|
|
1007
1007
|
src: match[2] || "",
|
|
1008
|
-
|
|
1008
|
+
caption: match[3] || ""
|
|
1009
|
+
// Renamed from 'title' to 'caption' for clarity
|
|
1009
1010
|
}
|
|
1010
1011
|
})
|
|
1011
1012
|
}
|
|
@@ -1016,13 +1017,24 @@ var ImageExtension = {
|
|
|
1016
1017
|
render: (token) => {
|
|
1017
1018
|
const src = token.attributes?.src || "";
|
|
1018
1019
|
const alt = token.attributes?.alt || "";
|
|
1019
|
-
const
|
|
1020
|
-
const titleAttr = title ? ` title="${escapeHtml(title)}"` : "";
|
|
1020
|
+
const caption = token.attributes?.caption || "";
|
|
1021
1021
|
const format = token.attributes?.format || "html";
|
|
1022
|
+
if (caption) {
|
|
1023
|
+
if (format === "html") {
|
|
1024
|
+
return `<figure style="margin: 16px 0; text-align: center;">
|
|
1025
|
+
<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; border-radius: 8px;" loading="lazy" />
|
|
1026
|
+
<figcaption style="margin-top: 8px; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</figcaption>
|
|
1027
|
+
</figure>`;
|
|
1028
|
+
}
|
|
1029
|
+
return `<figure class="my-4 text-center">
|
|
1030
|
+
<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="max-w-full h-auto rounded-lg" loading="lazy" />
|
|
1031
|
+
<figcaption class="mt-2 text-sm text-gray-500 italic">${escapeHtml(caption)}</figcaption>
|
|
1032
|
+
</figure>`;
|
|
1033
|
+
}
|
|
1022
1034
|
if (format === "html") {
|
|
1023
|
-
return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"
|
|
1035
|
+
return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0;" loading="lazy" />`;
|
|
1024
1036
|
}
|
|
1025
|
-
return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"
|
|
1037
|
+
return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="max-w-full h-auto rounded-lg my-4" loading="lazy" />`;
|
|
1026
1038
|
}
|
|
1027
1039
|
}
|
|
1028
1040
|
]
|
|
@@ -1074,12 +1086,31 @@ var ListExtension = {
|
|
|
1074
1086
|
name: "list",
|
|
1075
1087
|
parseRules: [
|
|
1076
1088
|
{
|
|
1077
|
-
name: "list-item",
|
|
1089
|
+
name: "unordered-list-item",
|
|
1078
1090
|
pattern: /^(\s*)[-*+]\s+(.+)$/m,
|
|
1079
1091
|
render: (match) => ({
|
|
1080
1092
|
type: "list-item",
|
|
1081
1093
|
content: match[2] || "",
|
|
1082
|
-
raw: match[0] || ""
|
|
1094
|
+
raw: match[0] || "",
|
|
1095
|
+
attributes: {
|
|
1096
|
+
indent: match[1]?.length || 0,
|
|
1097
|
+
ordered: false,
|
|
1098
|
+
marker: match[1] ? match[0].match(/[-*+]/)?.[0] : "-"
|
|
1099
|
+
}
|
|
1100
|
+
})
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
name: "ordered-list-item",
|
|
1104
|
+
pattern: /^(\s*)(\d+)\.\s+(.+)$/m,
|
|
1105
|
+
render: (match) => ({
|
|
1106
|
+
type: "ordered-list-item",
|
|
1107
|
+
content: match[3] || "",
|
|
1108
|
+
raw: match[0] || "",
|
|
1109
|
+
attributes: {
|
|
1110
|
+
indent: match[1]?.length || 0,
|
|
1111
|
+
ordered: true,
|
|
1112
|
+
number: parseInt(match[2] || "1")
|
|
1113
|
+
}
|
|
1083
1114
|
})
|
|
1084
1115
|
}
|
|
1085
1116
|
],
|
|
@@ -1094,6 +1125,17 @@ var ListExtension = {
|
|
|
1094
1125
|
}
|
|
1095
1126
|
return `<li>${content}</li>`;
|
|
1096
1127
|
}
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
type: "ordered-list-item",
|
|
1131
|
+
render: (token) => {
|
|
1132
|
+
const format = token.attributes?.format || "tailwind";
|
|
1133
|
+
const content = token.attributes?.renderedChildren || escapeHtml(token.content);
|
|
1134
|
+
if (format === "html") {
|
|
1135
|
+
return `<li>${content}</li>`;
|
|
1136
|
+
}
|
|
1137
|
+
return `<li>${content}</li>`;
|
|
1138
|
+
}
|
|
1097
1139
|
}
|
|
1098
1140
|
]
|
|
1099
1141
|
};
|
|
@@ -1108,6 +1150,7 @@ var TaskListExtension = {
|
|
|
1108
1150
|
content: match[3] || "",
|
|
1109
1151
|
raw: match[0] || "",
|
|
1110
1152
|
attributes: {
|
|
1153
|
+
indent: match[1]?.length || 0,
|
|
1111
1154
|
checked: String((match[2] || "").toLowerCase() === "x")
|
|
1112
1155
|
}
|
|
1113
1156
|
})
|
|
@@ -1173,6 +1216,35 @@ var TextExtension = {
|
|
|
1173
1216
|
]
|
|
1174
1217
|
};
|
|
1175
1218
|
|
|
1219
|
+
// src/extensions/core/strikethrough.ts
|
|
1220
|
+
var StrikethroughExtension = {
|
|
1221
|
+
name: "strikethrough",
|
|
1222
|
+
parseRules: [
|
|
1223
|
+
{
|
|
1224
|
+
name: "strikethrough",
|
|
1225
|
+
pattern: /~~((?:(?!~~).)+)~~/,
|
|
1226
|
+
render: (match) => ({
|
|
1227
|
+
type: "strikethrough",
|
|
1228
|
+
content: match[1] || "",
|
|
1229
|
+
raw: match[0] || ""
|
|
1230
|
+
})
|
|
1231
|
+
}
|
|
1232
|
+
],
|
|
1233
|
+
renderRules: [
|
|
1234
|
+
{
|
|
1235
|
+
type: "strikethrough",
|
|
1236
|
+
render: (token) => {
|
|
1237
|
+
const content = escapeHtml(token.content);
|
|
1238
|
+
const format = token.attributes?.format;
|
|
1239
|
+
if (format === "html") {
|
|
1240
|
+
return `<del style="text-decoration: line-through; color: #6b7280;">${content}</del>`;
|
|
1241
|
+
}
|
|
1242
|
+
return `<del class="line-through text-gray-500">${content}</del>`;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
]
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1176
1248
|
// src/extensions/core/index.ts
|
|
1177
1249
|
var CoreExtensions = [
|
|
1178
1250
|
TextExtension,
|
|
@@ -1187,6 +1259,7 @@ var CoreExtensions = [
|
|
|
1187
1259
|
TaskListExtension,
|
|
1188
1260
|
BlockquoteExtension,
|
|
1189
1261
|
HorizontalRuleExtension,
|
|
1262
|
+
StrikethroughExtension,
|
|
1190
1263
|
ParagraphExtension,
|
|
1191
1264
|
LineBreakExtension
|
|
1192
1265
|
];
|