@oh-my-pi/pi-utils 14.3.0 → 14.4.0

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/prompt.ts +17 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "14.3.0",
4
+ "version": "14.4.0",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/bun": "^1.3.13",
41
- "@oh-my-pi/pi-natives": "14.3.0"
41
+ "@oh-my-pi/pi-natives": "14.4.0"
42
42
  },
43
43
  "engines": {
44
44
  "bun": ">=1.3.7"
package/src/prompt.ts CHANGED
@@ -402,8 +402,24 @@ export function registerPartial(name: string, fn: Template): void {
402
402
  handlebars.registerPartial(name, fn);
403
403
  }
404
404
 
405
+ /**
406
+ * Handlebars' lexer greedily matches `}}}` as `CLOSE_UNESCAPED` (the close of a
407
+ * triple-stash `{{{ ... }}}`). When a regular helper close `}}` is immediately
408
+ * followed by a literal `}` (common in compact JSON examples like
409
+ * `{del:{{href ...}}}`), the lexer mistakes the trailing `}}}` for a triple-close
410
+ * and rejects the input.
411
+ *
412
+ * We never use triple-stash (it's redundant under `noEscape: true`), so any run
413
+ * of 3+ closing braces is unambiguously "helper close `}}`" + "literal `}`s".
414
+ * Inject a no-op comment between them so the lexer tokenizes the helper close
415
+ * cleanly and treats the rest as content.
416
+ */
417
+ function disambiguateClosingBraces(template: string): string {
418
+ return template.replace(/\}\}(\}+)/g, "}}{{!---}}$1");
419
+ }
420
+
405
421
  export function compile(template: string): (context: TemplateContext) => string {
406
- return handlebars.compile(template, { noEscape: true, strict: false });
422
+ return handlebars.compile(disambiguateClosingBraces(template), { noEscape: true, strict: false });
407
423
  }
408
424
 
409
425
  export function render(template: string, context: TemplateContext = {}): string {