@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 CHANGED
@@ -564,7 +564,7 @@ declare const ParagraphExtension: Extension;
564
564
 
565
565
  declare const TextExtension: Extension;
566
566
 
567
- declare const CoreExtensions: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
567
+ declare const CoreExtensions: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
568
568
 
569
569
  /**
570
570
  * @changerawr/markdown - Main package exports
@@ -623,7 +623,7 @@ declare const markdown: {
623
623
  readonly parseCum: typeof parseCum;
624
624
  readonly ChangerawrMarkdown: typeof ChangerawrMarkdown;
625
625
  readonly extensions: {
626
- readonly core: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
626
+ readonly core: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
627
627
  readonly Text: Extension;
628
628
  readonly Heading: Extension;
629
629
  readonly Bold: Extension;
package/dist/index.d.ts CHANGED
@@ -564,7 +564,7 @@ declare const ParagraphExtension: Extension;
564
564
 
565
565
  declare const TextExtension: Extension;
566
566
 
567
- declare const CoreExtensions: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
567
+ declare const CoreExtensions: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
568
568
 
569
569
  /**
570
570
  * @changerawr/markdown - Main package exports
@@ -623,7 +623,7 @@ declare const markdown: {
623
623
  readonly parseCum: typeof parseCum;
624
624
  readonly ChangerawrMarkdown: typeof ChangerawrMarkdown;
625
625
  readonly extensions: {
626
- readonly core: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
626
+ readonly core: readonly [Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension, Extension];
627
627
  readonly Text: Extension;
628
628
  readonly Heading: Extension;
629
629
  readonly Bold: Extension;
package/dist/index.js CHANGED
@@ -1207,7 +1207,8 @@ var ImageExtension = {
1207
1207
  attributes: {
1208
1208
  alt: match[1] || "",
1209
1209
  src: match[2] || "",
1210
- title: match[3] || ""
1210
+ caption: match[3] || ""
1211
+ // Renamed from 'title' to 'caption' for clarity
1211
1212
  }
1212
1213
  })
1213
1214
  }
@@ -1218,13 +1219,24 @@ var ImageExtension = {
1218
1219
  render: (token) => {
1219
1220
  const src = token.attributes?.src || "";
1220
1221
  const alt = token.attributes?.alt || "";
1221
- const title = token.attributes?.title || "";
1222
- const titleAttr = title ? ` title="${escapeHtml(title)}"` : "";
1222
+ const caption = token.attributes?.caption || "";
1223
1223
  const format = token.attributes?.format || "html";
1224
+ if (caption) {
1225
+ if (format === "html") {
1226
+ return `<figure style="margin: 16px 0; text-align: center;">
1227
+ <img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; border-radius: 8px;" loading="lazy" />
1228
+ <figcaption style="margin-top: 8px; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</figcaption>
1229
+ </figure>`;
1230
+ }
1231
+ return `<figure class="my-4 text-center">
1232
+ <img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="max-w-full h-auto rounded-lg" loading="lazy" />
1233
+ <figcaption class="mt-2 text-sm text-gray-500 italic">${escapeHtml(caption)}</figcaption>
1234
+ </figure>`;
1235
+ }
1224
1236
  if (format === "html") {
1225
- return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"${titleAttr} style="max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0;" loading="lazy" />`;
1237
+ return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0;" loading="lazy" />`;
1226
1238
  }
1227
- return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}"${titleAttr} class="max-w-full h-auto rounded-lg my-4" loading="lazy" />`;
1239
+ return `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="max-w-full h-auto rounded-lg my-4" loading="lazy" />`;
1228
1240
  }
1229
1241
  }
1230
1242
  ]
@@ -1276,12 +1288,31 @@ var ListExtension = {
1276
1288
  name: "list",
1277
1289
  parseRules: [
1278
1290
  {
1279
- name: "list-item",
1291
+ name: "unordered-list-item",
1280
1292
  pattern: /^(\s*)[-*+]\s+(.+)$/m,
1281
1293
  render: (match) => ({
1282
1294
  type: "list-item",
1283
1295
  content: match[2] || "",
1284
- raw: match[0] || ""
1296
+ raw: match[0] || "",
1297
+ attributes: {
1298
+ indent: match[1]?.length || 0,
1299
+ ordered: false,
1300
+ marker: match[1] ? match[0].match(/[-*+]/)?.[0] : "-"
1301
+ }
1302
+ })
1303
+ },
1304
+ {
1305
+ name: "ordered-list-item",
1306
+ pattern: /^(\s*)(\d+)\.\s+(.+)$/m,
1307
+ render: (match) => ({
1308
+ type: "ordered-list-item",
1309
+ content: match[3] || "",
1310
+ raw: match[0] || "",
1311
+ attributes: {
1312
+ indent: match[1]?.length || 0,
1313
+ ordered: true,
1314
+ number: parseInt(match[2] || "1")
1315
+ }
1285
1316
  })
1286
1317
  }
1287
1318
  ],
@@ -1296,6 +1327,17 @@ var ListExtension = {
1296
1327
  }
1297
1328
  return `<li>${content}</li>`;
1298
1329
  }
1330
+ },
1331
+ {
1332
+ type: "ordered-list-item",
1333
+ render: (token) => {
1334
+ const format = token.attributes?.format || "tailwind";
1335
+ const content = token.attributes?.renderedChildren || escapeHtml(token.content);
1336
+ if (format === "html") {
1337
+ return `<li>${content}</li>`;
1338
+ }
1339
+ return `<li>${content}</li>`;
1340
+ }
1299
1341
  }
1300
1342
  ]
1301
1343
  };
@@ -1310,6 +1352,7 @@ var TaskListExtension = {
1310
1352
  content: match[3] || "",
1311
1353
  raw: match[0] || "",
1312
1354
  attributes: {
1355
+ indent: match[1]?.length || 0,
1313
1356
  checked: String((match[2] || "").toLowerCase() === "x")
1314
1357
  }
1315
1358
  })
@@ -1375,6 +1418,35 @@ var TextExtension = {
1375
1418
  ]
1376
1419
  };
1377
1420
 
1421
+ // src/extensions/core/strikethrough.ts
1422
+ var StrikethroughExtension = {
1423
+ name: "strikethrough",
1424
+ parseRules: [
1425
+ {
1426
+ name: "strikethrough",
1427
+ pattern: /~~((?:(?!~~).)+)~~/,
1428
+ render: (match) => ({
1429
+ type: "strikethrough",
1430
+ content: match[1] || "",
1431
+ raw: match[0] || ""
1432
+ })
1433
+ }
1434
+ ],
1435
+ renderRules: [
1436
+ {
1437
+ type: "strikethrough",
1438
+ render: (token) => {
1439
+ const content = escapeHtml(token.content);
1440
+ const format = token.attributes?.format;
1441
+ if (format === "html") {
1442
+ return `<del style="text-decoration: line-through; color: #6b7280;">${content}</del>`;
1443
+ }
1444
+ return `<del class="line-through text-gray-500">${content}</del>`;
1445
+ }
1446
+ }
1447
+ ]
1448
+ };
1449
+
1378
1450
  // src/extensions/core/index.ts
1379
1451
  var CoreExtensions = [
1380
1452
  TextExtension,
@@ -1389,6 +1461,7 @@ var CoreExtensions = [
1389
1461
  TaskListExtension,
1390
1462
  BlockquoteExtension,
1391
1463
  HorizontalRuleExtension,
1464
+ StrikethroughExtension,
1392
1465
  ParagraphExtension,
1393
1466
  LineBreakExtension
1394
1467
  ];