Annotate href labels with PDF link targets

This commit is contained in:
gloamxun committed 2026-10-19 21:33:26 +08:00
1 parent 88646c9453
commit 05d7980561
7 files changed
+68 -35

No files matched your search

+20
View File
@@ -1551,6 +1551,26 @@ After text.
);
}
#[test]
fn href_text_creates_a_pdf_link_annotation() {
let source = r"\documentclass{article}
\begin{document}
See \href{https://example.com/target}{Click here} now.
\end{document}";
let pdf = CompilerSession::default()
.compile(source, "href-link.tex")
.expect("href PDF");
let text = String::from_utf8_lossy(&pdf);
assert!(
text.contains("/Subtype/Link"),
"href text should be clickable"
);
assert!(
text.contains("https://example.com/target"),
"annotation should carry the href target"
);
}
#[test]
fn url_text_creates_a_pdf_link_annotation() {
let source = r"\documentclass{article}