@oh-my-pi/pi-utils 17.3.4 → 17.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [17.3.5] - 2026-08-16
6
+
7
+ ### Fixed
8
+
9
+ - Fixed the Markdown renderer incorrectly breaking into a raw code block when a 4-space-indented line (such as a box-drawing tree child under a └── branch) directly followed paragraph text; it now correctly stays part of the paragraph, matching standard Markdown behavior.
10
+
5
11
  ## [17.3.2] - 2026-08-13
6
12
 
7
13
  ### Fixed
@@ -64,9 +64,12 @@ export declare function readSseEvents(stream: ReadableStream<Uint8Array>, signal
64
64
  * Uses `Bun.JSONL.parseChunk` internally. On parse errors, the malformed
65
65
  * region is skipped up to the next newline and parsing continues.
66
66
  *
67
+ * @param options.onMalformedRecord Called once for every skipped JSONL record.
67
68
  * @example
68
69
  * ```ts
69
70
  * const entries = parseJsonlLenient<MyType>(fileContents);
70
71
  * ```
71
72
  */
72
- export declare function parseJsonlLenient<T>(buffer: string): T[];
73
+ export declare function parseJsonlLenient<T>(buffer: string, options?: {
74
+ onMalformedRecord?: () => void;
75
+ }): T[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "17.3.4",
4
+ "version": "17.3.5",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -31,7 +31,7 @@
31
31
  "fmt": "biome format --write ."
32
32
  },
33
33
  "dependencies": {
34
- "@oh-my-pi/pi-natives": "17.3.4"
34
+ "@oh-my-pi/pi-natives": "17.3.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/bun": "^1.3.14"
@@ -1071,8 +1071,20 @@ function blockTokens(src: string, lexer: Lexer, output: Token[]): Token[] {
1071
1071
  }
1072
1072
  let raw = line;
1073
1073
  i++;
1074
- while (i < lines.length && !isBlockStart(lines, i)) {
1075
- raw += lines[i++]!;
1074
+ // An indented code block cannot interrupt a paragraph (CommonMark lazy
1075
+ // continuation): a line indented by at least 4 spaces directly attached to
1076
+ // paragraph text stays inside the paragraph, bypassing every block-start
1077
+ // probe — matching marked's paragraph rule. After a whitespace-padded
1078
+ // blank line the indent is no longer attached, so it still opens an
1079
+ // indented code block.
1080
+ let prevBlankish = false;
1081
+ while (i < lines.length) {
1082
+ const next = lines[i]!;
1083
+ const indented = next.trim() !== "" && /^ {4}/.test(next);
1084
+ if (indented ? prevBlankish : isBlockStart(lines, i)) break;
1085
+ prevBlankish = next.trim() === "";
1086
+ raw += next;
1087
+ i++;
1076
1088
  }
1077
1089
  const text = stripFinalNewline(raw);
1078
1090
  const tokens: Token[] = [];
package/src/stream.ts CHANGED
@@ -446,12 +446,13 @@ export async function* readSseEvents(
446
446
  * Uses `Bun.JSONL.parseChunk` internally. On parse errors, the malformed
447
447
  * region is skipped up to the next newline and parsing continues.
448
448
  *
449
+ * @param options.onMalformedRecord Called once for every skipped JSONL record.
449
450
  * @example
450
451
  * ```ts
451
452
  * const entries = parseJsonlLenient<MyType>(fileContents);
452
453
  * ```
453
454
  */
454
- export function parseJsonlLenient<T>(buffer: string): T[] {
455
+ export function parseJsonlLenient<T>(buffer: string, options: { onMalformedRecord?: () => void } = {}): T[] {
455
456
  let entries: T[] | undefined;
456
457
 
457
458
  while (buffer.length > 0) {
@@ -466,11 +467,16 @@ export function parseJsonlLenient<T>(buffer: string): T[] {
466
467
  }
467
468
  if (error) {
468
469
  const nextNewline = buffer.indexOf("\n", read);
470
+ const malformedEnd = nextNewline === -1 ? buffer.length : nextNewline;
471
+ if (buffer.substring(read, malformedEnd).trim().length > 0) options.onMalformedRecord?.();
469
472
  if (nextNewline === -1) break;
470
473
  buffer = buffer.substring(nextNewline + 1);
471
474
  continue;
472
475
  }
473
- if (read === 0) break;
476
+ if (read === 0) {
477
+ if (buffer.trim().length > 0) options.onMalformedRecord?.();
478
+ break;
479
+ }
474
480
  buffer = buffer.substring(read);
475
481
  if (done) break;
476
482
  }