pi-studio 0.9.25 → 0.9.26

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 (3) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/index.ts +24 -2
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to `pi-studio` are documented here.
4
4
 
5
+ ## [0.9.26] — 2026-06-04
6
+
7
+ ### Fixed
8
+ - Made Studio Markdown previews compatible with older Pandoc versions by falling back to `--self-contained` when `--embed-resources` is unavailable.
9
+
5
10
  ## [0.9.25] — 2026-06-01
6
11
 
7
12
  ### Changed
package/index.ts CHANGED
@@ -5898,6 +5898,28 @@ function decorateStudioPandocSyntaxHtml(html: string): string {
5898
5898
  );
5899
5899
  }
5900
5900
 
5901
+ const studioPandocHtmlResourceFlagCache = new Map<string, Promise<"--embed-resources" | "--self-contained">>();
5902
+
5903
+ async function getStudioPandocHtmlResourceFlag(pandocCommand: string): Promise<"--embed-resources" | "--self-contained"> {
5904
+ let cached = studioPandocHtmlResourceFlagCache.get(pandocCommand);
5905
+ if (!cached) {
5906
+ cached = runStudioSubprocess(pandocCommand, ["--help"], {
5907
+ timeoutMs: 5_000,
5908
+ stdoutMaxBytes: 250_000,
5909
+ stderrMaxBytes: 20_000,
5910
+ label: "pandoc capability probe",
5911
+ notFoundMessage: "pandoc was not found. Install pandoc or set PANDOC_PATH to the pandoc binary.",
5912
+ }).then((result) => {
5913
+ if (result.code !== 0) {
5914
+ throw new Error(`pandoc capability probe failed with exit code ${result.code}${result.stderr ? `: ${result.stderr}` : ""}`);
5915
+ }
5916
+ return result.stdout.includes("--embed-resources") ? "--embed-resources" : "--self-contained";
5917
+ });
5918
+ studioPandocHtmlResourceFlagCache.set(pandocCommand, cached);
5919
+ }
5920
+ return cached;
5921
+ }
5922
+
5901
5923
  async function renderStudioMarkdownWithPandoc(markdown: string, isLatex?: boolean, resourcePath?: string, sourcePath?: string): Promise<string> {
5902
5924
  const pandocCommand = process.env.PANDOC_PATH?.trim() || "pandoc";
5903
5925
  const markdownWithNormalizedFences = isLatex ? markdown : normalizeStudioMarkdownSmartFences(markdown);
@@ -5925,7 +5947,7 @@ async function renderStudioMarkdownWithPandoc(markdown: string, isLatex?: boolea
5925
5947
  await mkdir(htmlTemplateDir, { recursive: true });
5926
5948
  const htmlTemplatePath = join(htmlTemplateDir, "template.html");
5927
5949
  await writeFile(htmlTemplatePath, STUDIO_PANDOC_HTML_FRAGMENT_TEMPLATE, "utf-8");
5928
- args.push("--embed-resources", "--standalone", `--template=${htmlTemplatePath}`);
5950
+ args.push(await getStudioPandocHtmlResourceFlag(pandocCommand), "--standalone", `--template=${htmlTemplatePath}`);
5929
5951
  }
5930
5952
  const normalizedMarkdown = isLatex
5931
5953
  ? sourceWithResolvedRefs
@@ -5955,7 +5977,7 @@ async function renderStudioMarkdownWithPandoc(markdown: string, isLatex?: boolea
5955
5977
  }
5956
5978
 
5957
5979
  let renderedHtml = pandocResult.stdout;
5958
- // When --standalone was used for --embed-resources, extract only the <body> content.
5980
+ // When --standalone is used for embedded resources, extract only the <body> content.
5959
5981
  if (resourcePath) {
5960
5982
  const bodyMatch = renderedHtml.match(/<body[^>]*>([\s\S]*)<\/body>/i);
5961
5983
  if (!bodyMatch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-studio",
3
- "version": "0.9.25",
3
+ "version": "0.9.26",
4
4
  "description": "Two-pane browser workspace for pi with prompt/response editing, annotations, critiques, active quiz, prompt/response history, live previews, and tmux-backed REPL/literate REPL workflows",
5
5
  "type": "module",
6
6
  "license": "MIT",