@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.mjs CHANGED
@@ -1096,7 +1096,8 @@ var ImageExtension = {
1096
1096
  attributes: {
1097
1097
  alt: match[1] || "",
1098
1098
  src: match[2] || "",
1099
- title: match[3] || ""
1099
+ caption: match[3] || ""
1100
+ // Renamed from 'title' to 'caption' for clarity
1100
1101
  }
1101
1102
  })
1102
1103
  }
@@ -1107,13 +1108,24 @@ var ImageExtension = {
1107
1108
  render: (token) => {
1108
1109
  const src = token.attributes?.src || "";
1109
1110
  const alt = token.attributes?.alt || "";
1110
- const title = token.attributes?.title || "";
1111
- const titleAttr = title ? ` title="${escapeHtml(title)}"` : "";
1111
+ const caption = token.attributes?.caption || "";
1112
1112
  const format = token.attributes?.format || "html";
1113
+ if (caption) {
1114
+ if (format === "html") {
1115
+ return `<figure style="margin: 16px 0; text-align: center;">
1116
+ <img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; border-radius: 8px;" loading="lazy" />
1117
+ <figcaption style="margin-top: 8px; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</figcaption>
1118
+ </figure>`;
1119
+ }
1120
+ return `<figure class="my-4 text-center">
1121
+ <img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="max-w-full h-auto rounded-lg" loading="lazy" />
1122
+ <figcaption class="mt-2 text-sm text-gray-500 italic">${escapeHtml(caption)}</figcaption>
1123
+ </figure>`;
1124
+ }
1113
1125
  if (format === "html") {
1114
- return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"${titleAttr} style="max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0;" loading="lazy" />`;
1126
+ return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0;" loading="lazy" />`;
1115
1127
  }
1116
- return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"${titleAttr} class="max-w-full h-auto rounded-lg my-4" loading="lazy" />`;
1128
+ return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="max-w-full h-auto rounded-lg my-4" loading="lazy" />`;
1117
1129
  }
1118
1130
  }
1119
1131
  ]
@@ -1165,12 +1177,31 @@ var ListExtension = {
1165
1177
  name: "list",
1166
1178
  parseRules: [
1167
1179
  {
1168
- name: "list-item",
1180
+ name: "unordered-list-item",
1169
1181
  pattern: /^(\s*)[-*+]\s+(.+)$/m,
1170
1182
  render: (match) => ({
1171
1183
  type: "list-item",
1172
1184
  content: match[2] || "",
1173
- raw: match[0] || ""
1185
+ raw: match[0] || "",
1186
+ attributes: {
1187
+ indent: match[1]?.length || 0,
1188
+ ordered: false,
1189
+ marker: match[1] ? match[0].match(/[-*+]/)?.[0] : "-"
1190
+ }
1191
+ })
1192
+ },
1193
+ {
1194
+ name: "ordered-list-item",
1195
+ pattern: /^(\s*)(\d+)\.\s+(.+)$/m,
1196
+ render: (match) => ({
1197
+ type: "ordered-list-item",
1198
+ content: match[3] || "",
1199
+ raw: match[0] || "",
1200
+ attributes: {
1201
+ indent: match[1]?.length || 0,
1202
+ ordered: true,
1203
+ number: parseInt(match[2] || "1")
1204
+ }
1174
1205
  })
1175
1206
  }
1176
1207
  ],
@@ -1185,6 +1216,17 @@ var ListExtension = {
1185
1216
  }
1186
1217
  return `<li>${content}</li>`;
1187
1218
  }
1219
+ },
1220
+ {
1221
+ type: "ordered-list-item",
1222
+ render: (token) => {
1223
+ const format = token.attributes?.format || "tailwind";
1224
+ const content = token.attributes?.renderedChildren || escapeHtml(token.content);
1225
+ if (format === "html") {
1226
+ return `<li>${content}</li>`;
1227
+ }
1228
+ return `<li>${content}</li>`;
1229
+ }
1188
1230
  }
1189
1231
  ]
1190
1232
  };
@@ -1199,6 +1241,7 @@ var TaskListExtension = {
1199
1241
  content: match[3] || "",
1200
1242
  raw: match[0] || "",
1201
1243
  attributes: {
1244
+ indent: match[1]?.length || 0,
1202
1245
  checked: String((match[2] || "").toLowerCase() === "x")
1203
1246
  }
1204
1247
  })
@@ -1264,6 +1307,35 @@ var TextExtension = {
1264
1307
  ]
1265
1308
  };
1266
1309
 
1310
+ // src/extensions/core/strikethrough.ts
1311
+ var StrikethroughExtension = {
1312
+ name: "strikethrough",
1313
+ parseRules: [
1314
+ {
1315
+ name: "strikethrough",
1316
+ pattern: /~~((?:(?!~~).)+)~~/,
1317
+ render: (match) => ({
1318
+ type: "strikethrough",
1319
+ content: match[1] || "",
1320
+ raw: match[0] || ""
1321
+ })
1322
+ }
1323
+ ],
1324
+ renderRules: [
1325
+ {
1326
+ type: "strikethrough",
1327
+ render: (token) => {
1328
+ const content = escapeHtml(token.content);
1329
+ const format = token.attributes?.format;
1330
+ if (format === "html") {
1331
+ return `<del style="text-decoration: line-through; color: #6b7280;">${content}</del>`;
1332
+ }
1333
+ return `<del class="line-through text-gray-500">${content}</del>`;
1334
+ }
1335
+ }
1336
+ ]
1337
+ };
1338
+
1267
1339
  // src/extensions/core/index.ts
1268
1340
  var CoreExtensions = [
1269
1341
  TextExtension,
@@ -1278,6 +1350,7 @@ var CoreExtensions = [
1278
1350
  TaskListExtension,
1279
1351
  BlockquoteExtension,
1280
1352
  HorizontalRuleExtension,
1353
+ StrikethroughExtension,
1281
1354
  ParagraphExtension,
1282
1355
  LineBreakExtension
1283
1356
  ];