@devries-cameron20 / t3code Mirror · read-only / commits / 6647b0a761
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 00:45 UTC

fix(web): rich text previews keep paragraphs that end with a backslash (#30812)

Co-authored-by: Geezy <igor.licko@gloryck.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

TheGuyWithHAT committed Nov 9, 2026 at 15:35 UTC 6647b0a761ff7a1287047a9bb5fd5b63772f456b
2 files changed +20
apps/web/src/components/files/FilePreviewPanel.test.ts
+18
@@ -173,6 +173,24 @@ describe("document preview contents", () => {
173 expect(html).not.toContain("https:");
174 });
175
176 + it("treats a backslash before a line break as a paragraph break, as TextEdit writes them", () => {
177 + const html = (rtf: string) => {
178 + const result = openRtf(bytes(rtf));
179 + if (result.type !== "document") throw new Error("Expected document");
180 + return result.pages.map((page) => page.html);
181 + };
182 + const textEdit = String.raw`{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}
183 +\pard\f0\fs24 \cf0 First\
184 +Second\
185 +\
186 +Third}`;
187 + const expected = html(
188 + String.raw`{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\pard\f0\fs24 \cf0 First\par Second\par \par Third}`,
189 + );
190 + expect(html(textEdit)).toEqual(expected);
191 + expect(html(textEdit.replaceAll("\n", "\r\n"))).toEqual(expected);
192 + });
193 +
194 it("preserves rich text page breaks and formatting without splitting hidden destinations", () => {
195 const result = openRtf(
196 bytes(String.raw`{\rtf1\b First\page Second\b0{\*\unknown \page hidden}\page Third\page}`),
apps/web/src/components/files/extendedDocumentPreview.ts
+2
@@ -565,6 +565,8 @@ export function openRtf(bytes: ArrayBuffer): OfficeWorkerResult {
565 const match = /^([a-z]+)(-?\d+)? ?/i.exec(source.slice(i));
566 if (!match) {
567 if (next === "~") emit("\u00a0");
568 + // A backslash before a line break is \par; TextEdit ends paragraphs this way.
569 + else if ((next === "\n" || next === "\r") && !state.skip) html += "<br>";
570 i++;
571 continue;
572 }