summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 01:25:06 -0300
committerGabriel Schneider <[email protected]>2026-10-01 01:35:12 -0300
commitb3bbad85c61f81c01fb983813ccc28ceb6361469 (patch)
tree5cdf4fa745d5ae2c098db463bfabddd48abd6d0e /test/pdf.zig
parentea28dbf4ce827ee5544562bd19453c68599d912f (diff)
downloadpardes-b3bbad85c61f81c01fb983813ccc28ceb6361469.tar.gz
pardes-b3bbad85c61f81c01fb983813ccc28ceb6361469.zip
A PDF's body puts each line of the page's text on a line of its own, not a heading and its paragraph run together with a space
MuPDF's text buffer joins the lines of one block with spaces, so a typst page's heading and the text under it read as one line ("Page one Hello normal PDF alpha."). The bridge now walks the structured text itself, structure blocks included, and ends each line with a newline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index d91f50a7..727a1515 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -352,6 +352,19 @@ test "a +PdfSections row's first number is the page: a section not there, or on
}
}
+test "a PDF's body puts each line of its text on a line of its own, never a heading run into the text under it" {
+ if (!pdf_enabled or platform == .web) return;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const p = try PdfLinkTests.init(tmp);
+ defer p.deinit();
+ const text = p.panes[0].?.pdf.?.ensureText(p.pdf_gpa);
+ // The page's three text runs, each its own line.
+ try std.testing.expect(std.mem.indexOf(u8, text, "target.txt\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, text, "https://example.com/same\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, text, "label\n") != null);
+}
+
test "PdfSections Look follows the exact owning PDF, not an equal path" {
if (!pdf_enabled or platform == .web) return;
const gpa = std.testing.allocator;