@changerawr/markdown 1.1.4 → 1.1.5

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.
@@ -1239,7 +1239,7 @@ var ChangerawrMarkdown = (() => {
1239
1239
  return processed;
1240
1240
  }
1241
1241
  recursivelyParseBlockContent(token) {
1242
- const blockTypes = ["alert", "blockquote"];
1242
+ const blockTypes = ["alert", "blockquote", "list-item", "task-item"];
1243
1243
  if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
1244
1244
  const children = this.parse(token.content);
1245
1245
  return __spreadProps(__spreadValues({}, token), {
@@ -1956,7 +1956,15 @@ var ChangerawrMarkdown = (() => {
1956
1956
  renderRules: [
1957
1957
  {
1958
1958
  type: "list-item",
1959
- render: (token) => `<li>${escapeHtml(token.content)}</li>`
1959
+ render: (token) => {
1960
+ var _a, _b;
1961
+ const format = ((_a = token.attributes) == null ? void 0 : _a.format) || "tailwind";
1962
+ const content = ((_b = token.attributes) == null ? void 0 : _b.renderedChildren) || escapeHtml(token.content);
1963
+ if (format === "html") {
1964
+ return `<li>${content}</li>`;
1965
+ }
1966
+ return `<li>${content}</li>`;
1967
+ }
1960
1968
  }
1961
1969
  ]
1962
1970
  };
@@ -1980,20 +1988,20 @@ var ChangerawrMarkdown = (() => {
1980
1988
  {
1981
1989
  type: "task-item",
1982
1990
  render: (token) => {
1983
- var _a, _b;
1991
+ var _a, _b, _c;
1984
1992
  const isChecked = ((_a = token.attributes) == null ? void 0 : _a.checked) === "true";
1985
- const escapedContent = escapeHtml(token.content);
1986
- const format = ((_b = token.attributes) == null ? void 0 : _b.format) || "html";
1993
+ const content = ((_b = token.attributes) == null ? void 0 : _b.renderedChildren) || escapeHtml(token.content);
1994
+ const format = ((_c = token.attributes) == null ? void 0 : _c.format) || "html";
1987
1995
  if (format === "html") {
1988
1996
  return `<div style="display: flex; align-items: center; gap: 8px; margin: 8px 0;">
1989
1997
  <input type="checkbox" ${isChecked ? "checked" : ""} disabled style="margin: 0;" />
1990
- <span${isChecked ? ' style="text-decoration: line-through; color: #6b7280;"' : ""}>${escapedContent}</span>
1998
+ <span${isChecked ? ' style="text-decoration: line-through; color: #6b7280;"' : ""}>${content}</span>
1991
1999
  </div>`;
1992
2000
  }
1993
2001
  return `<div class="flex items-center gap-2 my-2 task-list-item">
1994
- <input type="checkbox" ${isChecked ? "checked" : ""} disabled
2002
+ <input type="checkbox" ${isChecked ? "checked" : ""} disabled
1995
2003
  class="form-checkbox h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary" />
1996
- <span${isChecked ? ' class="line-through text-muted-foreground"' : ""}>${escapedContent}</span>
2004
+ <span${isChecked ? ' class="line-through text-muted-foreground"' : ""}>${content}</span>
1997
2005
  </div>`;
1998
2006
  }
1999
2007
  }
@@ -2062,16 +2070,16 @@ var ChangerawrMarkdown = (() => {
2062
2070
  parseRules: [
2063
2071
  {
2064
2072
  name: "alert",
2065
- pattern: /:::(\w+)(?:\s+(.*?))?\s*\n([\s\S]*?)\n:::/,
2073
+ pattern: /:::(\w+)(?: ([^\n]+))?\n([\s\S]*?)\n:::/,
2066
2074
  render: (match) => {
2067
- var _a;
2075
+ var _a, _b;
2068
2076
  return {
2069
2077
  type: "alert",
2070
2078
  content: ((_a = match[3]) == null ? void 0 : _a.trim()) || "",
2071
2079
  raw: match[0] || "",
2072
2080
  attributes: {
2073
2081
  type: match[1] || "info",
2074
- title: match[2] || ""
2082
+ title: ((_b = match[2]) == null ? void 0 : _b.trim()) || ""
2075
2083
  }
2076
2084
  };
2077
2085
  }
@@ -2,7 +2,7 @@ interface MarkdownToken {
2
2
  type: string;
3
3
  content: string;
4
4
  raw: string;
5
- attributes?: Record<string, string>;
5
+ attributes?: Record<string, string | number | boolean | Function | any>;
6
6
  children?: MarkdownToken[];
7
7
  }
8
8
  interface ParseRule {
@@ -2,7 +2,7 @@ interface MarkdownToken {
2
2
  type: string;
3
3
  content: string;
4
4
  raw: string;
5
- attributes?: Record<string, string>;
5
+ attributes?: Record<string, string | number | boolean | Function | any>;
6
6
  children?: MarkdownToken[];
7
7
  }
8
8
  interface ParseRule {
@@ -240,7 +240,7 @@ var MarkdownParser = class {
240
240
  return processed;
241
241
  }
242
242
  recursivelyParseBlockContent(token) {
243
- const blockTypes = ["alert", "blockquote"];
243
+ const blockTypes = ["alert", "blockquote", "list-item", "task-item"];
244
244
  if (blockTypes.includes(token.type) && token.content && token.content.trim()) {
245
245
  const children = this.parse(token.content);
246
246
  return {
@@ -951,7 +951,14 @@ var ListExtension = {
951
951
  renderRules: [
952
952
  {
953
953
  type: "list-item",
954
- render: (token) => `<li>${escapeHtml(token.content)}</li>`
954
+ render: (token) => {
955
+ const format = token.attributes?.format || "tailwind";
956
+ const content = token.attributes?.renderedChildren || escapeHtml(token.content);
957
+ if (format === "html") {
958
+ return `<li>${content}</li>`;
959
+ }
960
+ return `<li>${content}</li>`;
961
+ }
955
962
  }
956
963
  ]
957
964
  };
@@ -976,18 +983,18 @@ var TaskListExtension = {
976
983
  type: "task-item",
977
984
  render: (token) => {
978
985
  const isChecked = token.attributes?.checked === "true";
979
- const escapedContent = escapeHtml(token.content);
986
+ const content = token.attributes?.renderedChildren || escapeHtml(token.content);
980
987
  const format = token.attributes?.format || "html";
981
988
  if (format === "html") {
982
989
  return `<div style="display: flex; align-items: center; gap: 8px; margin: 8px 0;">
983
990
  <input type="checkbox" ${isChecked ? "checked" : ""} disabled style="margin: 0;" />
984
- <span${isChecked ? ' style="text-decoration: line-through; color: #6b7280;"' : ""}>${escapedContent}</span>
991
+ <span${isChecked ? ' style="text-decoration: line-through; color: #6b7280;"' : ""}>${content}</span>
985
992
  </div>`;
986
993
  }
987
994
  return `<div class="flex items-center gap-2 my-2 task-list-item">
988
- <input type="checkbox" ${isChecked ? "checked" : ""} disabled
995
+ <input type="checkbox" ${isChecked ? "checked" : ""} disabled
989
996
  class="form-checkbox h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary" />
990
- <span${isChecked ? ' class="line-through text-muted-foreground"' : ""}>${escapedContent}</span>
997
+ <span${isChecked ? ' class="line-through text-muted-foreground"' : ""}>${content}</span>
991
998
  </div>`;
992
999
  }
993
1000
  }
@@ -1055,7 +1062,7 @@ var AlertExtension = {
1055
1062
  parseRules: [
1056
1063
  {
1057
1064
  name: "alert",
1058
- pattern: /:::(\w+)(?:\s+(.*?))?\s*\n([\s\S]*?)\n:::/,
1065
+ pattern: /:::(\w+)(?: ([^\n]+))?\n([\s\S]*?)\n:::/,
1059
1066
  render: (match) => {
1060
1067
  return {
1061
1068
  type: "alert",
@@ -1063,7 +1070,7 @@ var AlertExtension = {
1063
1070
  raw: match[0] || "",
1064
1071
  attributes: {
1065
1072
  type: match[1] || "info",
1066
- title: match[2] || ""
1073
+ title: match[2]?.trim() || ""
1067
1074
  }
1068
1075
  };
1069
1076
  }