@mulmoclaude/markdown-utils 1.3.3 → 1.3.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.
@@ -3,5 +3,5 @@ export declare function formatLocalDate(timestampMs: number): string;
3
3
  export declare function buildPdfFilename(opts: {
4
4
  name: string | null | undefined;
5
5
  fallback: string;
6
- timestampMs?: number;
6
+ timestampMs?: number | undefined;
7
7
  }): string;
@@ -192,10 +192,9 @@ export function transformResolvableUrlsInHtml(html, transform) {
192
192
  if (!html)
193
193
  return html;
194
194
  return html.replace(RESOLVABLE_TAG_OUTER_RE, (tag) => {
195
- const tagNameMatch = TAG_NAME_RE.exec(tag);
196
- if (!tagNameMatch)
195
+ const tagName = TAG_NAME_RE.exec(tag)?.[1]?.toLowerCase();
196
+ if (tagName === undefined)
197
197
  return tag;
198
- const tagName = tagNameMatch[1].toLowerCase();
199
198
  const resolvableAttrs = RESOLVABLE_TAG_ATTRS[tagName];
200
199
  const srcsetAttrs = SRCSET_TAG_ATTRS[tagName];
201
200
  if (!resolvableAttrs && !srcsetAttrs)
@@ -60,8 +60,8 @@ function stepFence(line, state) {
60
60
  const quoteMatch = line.match(BLOCKQUOTE_PREFIX);
61
61
  const content = quoteMatch ? line.slice(quoteMatch[0].length) : line;
62
62
  const fenceMatch = content.match(FENCE_LINE);
63
- if (fenceMatch) {
64
- const [, , marker] = fenceMatch;
63
+ const marker = fenceMatch?.[2];
64
+ if (fenceMatch && marker !== undefined) {
65
65
  if (!state.inFence) {
66
66
  // Openers may carry an info string after the marker
67
67
  // (e.g. "```ts"). We don't need to keep it — just enter
@@ -111,11 +111,9 @@ function flipMark(line, match) {
111
111
  * source-side n-th line.
112
112
  */
113
113
  export function findTaskLines(source) {
114
- const lines = source.split("\n");
115
114
  const fence = { inFence: false, marker: null };
116
115
  const taskLines = [];
117
- for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
118
- const line = lines[lineIdx];
116
+ for (const [lineIdx, line] of source.split("\n").entries()) {
119
117
  if (stepFence(line, fence))
120
118
  continue;
121
119
  if (TASK_LINE.test(line))
@@ -144,15 +142,17 @@ export function findTaskLines(source) {
144
142
  export function toggleTaskAt(source, taskIndex) {
145
143
  if (!Number.isInteger(taskIndex) || taskIndex < 0)
146
144
  return null;
147
- const taskLines = findTaskLines(source);
148
- if (taskIndex >= taskLines.length)
145
+ const lineIdx = findTaskLines(source)[taskIndex];
146
+ if (lineIdx === undefined)
149
147
  return null;
150
- const lineIdx = taskLines[taskIndex];
151
148
  const lines = source.split("\n");
152
- const taskMatch = lines[lineIdx].match(TASK_LINE);
149
+ const line = lines[lineIdx];
150
+ if (line === undefined)
151
+ return null;
152
+ const taskMatch = line.match(TASK_LINE);
153
153
  if (!taskMatch)
154
154
  return null;
155
- lines[lineIdx] = flipMark(lines[lineIdx], taskMatch);
155
+ lines[lineIdx] = flipMark(line, taskMatch);
156
156
  return lines.join("\n");
157
157
  }
158
158
  /** Strip `disabled=""` from rendered GFM task checkboxes and tag them
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmoclaude/markdown-utils",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Browser-safe markdown / image rendering utilities shared by the MulmoClaude host and the markdown plugin",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,8 +33,8 @@
33
33
  "license": "MIT",
34
34
  "author": "Receptron Team",
35
35
  "dependencies": {
36
- "@mulmoclaude/common": "^1.1.1",
37
- "js-yaml": "^5.2.2",
36
+ "@mulmoclaude/common": "^1.1.2",
37
+ "js-yaml": "^5.2.3",
38
38
  "marked": "^18.0.7"
39
39
  },
40
40
  "peerDependencies": {