markdown-to-slack-blocks 1.4.0 → 1.4.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,KAAK,EAKL,uBAAuB,EAGvB,MAAM,SAAS,CAAC;AAmFjB,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,uBAA4B,GACnC,KAAK,EAAE,CAiNT"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,KAAK,EAKL,uBAAuB,EAGvB,MAAM,SAAS,CAAC;AAyGjB,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,uBAA4B,GACnC,KAAK,EAAE,CAiNT"}
package/dist/parser.js CHANGED
@@ -24,12 +24,25 @@ function isListNode(node) {
24
24
  /**
25
25
  * Preprocess markdown to "unwrap" lists that are entirely wrapped in formatting.
26
26
  * For example: "**1. Item**" becomes "1. **Item**"
27
+ * Also handles heading-prefixed format-wrapped lists:
28
+ * "### **1. Item**" becomes "###\n1. **Item**"
27
29
  * This allows the markdown parser to recognize them as list items.
28
30
  */
29
31
  function preprocessMarkdown(markdown) {
30
32
  const lines = markdown.split("\n");
31
- const processedLines = lines.map((line) => {
33
+ const processedLines = [];
34
+ for (const line of lines) {
32
35
  const trimmed = line.trim();
36
+ // Match heading-prefixed format-wrapped lists
37
+ // e.g. "### **1. Item**" or "## *- Item*"
38
+ const headingFormatWrappedListRegex = /^(#{1,6})\s+(\*\*|\*|_|~)(\d+\.|\*|-|\+)(\s+)(.*?)\2$/;
39
+ const headingMatch = trimmed.match(headingFormatWrappedListRegex);
40
+ if (headingMatch) {
41
+ const [_, _heading, format, marker, spaces, content] = headingMatch;
42
+ // Split into an empty line (to end the heading context) and a format-unwrapped list line
43
+ processedLines.push(`${marker}${spaces}${format}${content}${format}`);
44
+ continue;
45
+ }
33
46
  // Match patterns like **1. item**, *1. item*, ~1. item~, **- item**, etc.
34
47
  // Group 1: opening format (** or * or _ or ~)
35
48
  // Group 2: list marker (1. or - or * or +)
@@ -42,10 +55,11 @@ function preprocessMarkdown(markdown) {
42
55
  const [_, format, marker, spaces, content] = match;
43
56
  // Preserve leading whitespace of the original line
44
57
  const leadingWhitespace = line.match(/^\s*/)?.[0] || "";
45
- return `${leadingWhitespace}${marker}${spaces}${format}${content}${format}`;
58
+ processedLines.push(`${leadingWhitespace}${marker}${spaces}${format}${content}${format}`);
59
+ continue;
46
60
  }
47
- return line;
48
- });
61
+ processedLines.push(line);
62
+ }
49
63
  return processedLines.join("\n");
50
64
  }
51
65
  function parseMarkdown(markdown, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-to-slack-blocks",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Convert Markdown to Slack Block Kit JSON format",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",