import type { Component } from "@earendil-works/pi-tui"; import { readFileSync } from "fs"; import { describe, expect, it } from "vitest"; import { ansiLinesToHtml } from "../src/core/export-html/ansi-to-html.js"; import { createToolHtmlRenderer } from "../src/core/export-html/tool-renderer.js"; import type { ToolDefinition } from "../src/core/extensions/types.js"; import type { Theme } from "../src/modes/interactive/theme/theme.js"; describe("export HTML tool output whitespace", () => { it("preserves whitespace for plain-text tool output lines without preserving template whitespace", () => { const css = readFileSync(new URL("../src/core/export-html/template.css", import.meta.url), "utf-8"); expect(css).toMatch( /\.output-preview > div:not\(\.expand-hint\),\s*\.output-full > div:not\(\.expand-hint\) \{[\s\S]*?white-space:\s*pre-wrap;/, ); expect(css).toMatch(/\.ansi-line\s*\{[\s\S]*?white-space:\s*pre;/); expect(css).not.toMatch(/\.output-preview,\s*\.output-full\s*\{[\s\S]*?white-space:\s*pre-wrap;/); }); it("does not insert source whitespace between ANSI-rendered lines", () => { expect(ansiLinesToHtml(["one", "two"])).toBe('