From 11cfa44c2b466f428a72a47de96321d1f74dd499 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Sat, 24 Oct 2026 23:05:05 +0800 Subject: [PATCH] Test link annotations in route-D PDFs --- docs/ROUTE_D_PLAN.md | 2 +- docs/TEX_CORE.md | 2 +- tests/server.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 8515b15..82ff827 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`, `\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and -PDF opt-in with `?engine=route-d`). 686 workspace tests are green and no oracle +PDF opt-in with `?engine=route-d`). 687 workspace tests are green and no oracle fixture is ignored. Status after G1 (P0-P2): the paragraph model reproduces TeX's passes, diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 357a40d..bbf7735 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -367,7 +367,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address. `Engine::edit` preserves the face when reflowing an edited paragraph. -The crate currently has 405 unit tests plus eight route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 686 tests (405 route-D unit, 121 engine binary unit, 8 route-D integration, 35 oracle, 71 v1 integration, 41 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path. +The crate currently has 405 unit tests plus eight route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 687 tests (405 route-D unit, 121 engine binary unit, 8 route-D integration, 35 oracle, 71 v1 integration, 42 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path. ### M0 incremental demo diff --git a/tests/server.rs b/tests/server.rs index 8b9d37b..e9e7394 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -283,6 +283,32 @@ fn project_preview_expands_included_files() { assert!(svg.contains(">B"), "{svg}"); } +#[test] +fn project_pdf_annotates_href_links() { + let server = TestServer::start("route-d-link-pdf"); + let main = "\\documentclass{article}\n\\begin{document}\nVisit \\href{https://example.com/link}{Example}.\n\\end{document}\n"; + let put = server.request( + "PUT", + "/api/projects/hello/file?path=hello.tex", + main.as_bytes(), + "text/plain; charset=utf-8", + ); + assert_eq!(put.status, 200, "{}", put.text()); + let pdf = server.request( + "POST", + "/api/projects/hello/pdf?engine=route-d", + &[], + "application/pdf", + ); + assert_eq!(pdf.status, 200); + let text = String::from_utf8_lossy(&pdf.body); + assert!(text.contains("/Subtype /Link"), "missing link annotation"); + assert!( + text.contains("/URI (https://example.com/link)"), + "missing link target" + ); +} + #[test] fn project_preview_uses_the_engine_default() { let server = TestServer::start_with_env("route-d-default", &[("TEXRRA_ENGINE", "route-d")]);