pi-studio 0.5.47 → 0.5.49

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
@@ -4,6 +4,25 @@ All notable changes to `pi-studio` are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.49] — 2026-04-09
8
+
9
+ ### Fixed
10
+ - Markdown editor-preview comments are now substantially more robust on real pandoc-rendered documents, including smart punctuation and ellipsis normalization, mixed prose plus display-math sections, standalone display equations treated as whole units, MathJax fallback display math, standalone page-break commands, and raw-TeX commands that disappear from preview output.
11
+ - Preview comment block matching now avoids unsafe tiny substring fallbacks, so extra blank-line splits that create short paragraphs like `or` no longer derail later Markdown comment targets.
12
+ - Markdown HTML comments like `<!-- ... -->` are now stripped more consistently across both the main pandoc preview path and plain-markdown fallback rendering, including edge cases after unmatched inline backticks at line breaks.
13
+
14
+ ## [0.5.48] — 2026-04-07
15
+
16
+ ### Added
17
+ - Editor-preview comments now also work for code, plain-text, and diff files using line-based preview selection anchors, so code/text review can use the same local comments workflow as Markdown preview.
18
+
19
+ ### Fixed
20
+ - LaTeX editor preview now correctly treats `.tex`/LaTeX editor content as LaTeX in preview even when the document is only a fragment rather than a full `\documentclass` wrapper.
21
+ - Ordinary response preview no longer flips into LaTeX mode just because quoted LaTeX commands like `` `\\documentclass` `` or `` `\\begin{document}` `` appear in a normal response.
22
+
23
+ ### Changed
24
+ - LaTeX preview comments remain disabled for now; the earlier heuristic preview-side mapping attempts were removed in favor of keeping the rendering fixes and waiting for a more pipeline-grounded LaTeX comment design.
25
+
7
26
  ## [0.5.47] — 2026-04-07
8
27
 
9
28
  ### Changed
package/README.md CHANGED
@@ -18,7 +18,7 @@ Extension for [pi](https://pi.dev) that opens a local two-pane browser workspace
18
18
  - Supports one canonical full Studio view per Pi session, plus additional editor-only companion views when you just want extra editing/preview surfaces
19
19
  - Runs editor text directly, or asks for structured critique (auto/writing/code focus)
20
20
  - Includes a local persistent scratchpad for quick notes you want to keep out of the main editor until you're ready to copy or insert them
21
- - Includes local comments anchored to selections/lines, shown in a docked **Comments** rail, with **Comment** actions from raw-editor and editor-preview selections plus optional inline `[an: ...]` toggles when you want them in the document text
21
+ - Includes local comments anchored to selections/lines, shown in a docked **Comments** rail, with **Comment** actions from raw-editor selections plus editor-preview selections for Markdown and code/text/diff previews, alongside optional inline `[an: ...]` toggles when you want comments reflected in the document text
22
22
  - Browses response history (`Prev/Next/Last`) and loads either:
23
23
  - response text
24
24
  - critique notes/full critique
@@ -510,6 +510,71 @@
510
510
  });
511
511
  }
512
512
 
513
+ function stripMarkdownHtmlCommentsInSegment(markdown) {
514
+ const source = String(markdown || "");
515
+ let out = "";
516
+ let index = 0;
517
+ let codeSpanFenceLength = 0;
518
+ let inHtmlComment = false;
519
+
520
+ while (index < source.length) {
521
+ if (inHtmlComment) {
522
+ if (source.startsWith("-->", index)) {
523
+ inHtmlComment = false;
524
+ index += 3;
525
+ continue;
526
+ }
527
+ const ch = source[index];
528
+ if (ch === "\n" || ch === "\r") out += ch;
529
+ index += 1;
530
+ continue;
531
+ }
532
+
533
+ if (codeSpanFenceLength > 0) {
534
+ const fence = "`".repeat(codeSpanFenceLength);
535
+ if (source.startsWith(fence, index)) {
536
+ out += fence;
537
+ index += codeSpanFenceLength;
538
+ codeSpanFenceLength = 0;
539
+ continue;
540
+ }
541
+ const ch = source[index];
542
+ out += ch;
543
+ index += 1;
544
+ if (ch === "\n" || ch === "\r") {
545
+ codeSpanFenceLength = 0;
546
+ }
547
+ continue;
548
+ }
549
+
550
+ const backtickMatch = source.slice(index).match(/^`+/);
551
+ if (backtickMatch) {
552
+ const fence = backtickMatch[0] || "`";
553
+ codeSpanFenceLength = fence.length;
554
+ out += fence;
555
+ index += fence.length;
556
+ continue;
557
+ }
558
+
559
+ if (source.startsWith("<!--", index)) {
560
+ inHtmlComment = true;
561
+ index += 4;
562
+ continue;
563
+ }
564
+
565
+ out += source[index];
566
+ index += 1;
567
+ }
568
+
569
+ return out;
570
+ }
571
+
572
+ function stripMarkdownHtmlComments(text) {
573
+ return transformMarkdownOutsideFences(text, function(segment) {
574
+ return stripMarkdownHtmlCommentsInSegment(segment);
575
+ });
576
+ }
577
+
513
578
  function prepareMarkdownForPandocPreview(markdown, placeholderPrefix) {
514
579
  const placeholders = [];
515
580
  const prefix = typeof placeholderPrefix === "string" && placeholderPrefix
@@ -536,6 +601,7 @@
536
601
  renderPreviewAnnotationHtml: renderPreviewAnnotationHtml,
537
602
  replaceInlineAnnotationMarkers: replaceInlineAnnotationMarkers,
538
603
  stripAnnotationMarkers: stripAnnotationMarkers,
604
+ stripMarkdownHtmlComments: stripMarkdownHtmlComments,
539
605
  transformMarkdownOutsideFences: transformMarkdownOutsideFences,
540
606
  });
541
607