diff --git a/src/library/text.rs b/src/library/text.rs index 23d749380..e4d52396f 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -199,7 +199,7 @@ pub fn link(_: &mut EvalContext, args: &mut Args) -> TypResult { let url = args.expect::("url")?; let body = args.find().unwrap_or_else(|| { let mut template = Template::new(); - template.text(&url); + template.text(url.trim_start_matches("mailto:").trim_start_matches("tel:")); template }); diff --git a/tests/ref/text/links.png b/tests/ref/text/links.png index 2449880a6..38abf0c59 100644 Binary files a/tests/ref/text/links.png and b/tests/ref/text/links.png differ diff --git a/tests/typ/text/links.typ b/tests/typ/text/links.typ index e6aa1d89a..bea5f93ed 100644 --- a/tests/typ/text/links.typ +++ b/tests/typ/text/links.typ @@ -7,6 +7,10 @@ // With line break. This link appears #link("https://google.com/")[in the middle of] a paragraph. +// Prefix is trimmed. +Contact #link("mailto:hi@typst.app") or call #link("tel:123") for more information. + +--- // Styled with underline and color. #let link(url, body) = link(url, font(fill: rgb("283663"), underline(body))) You could also make the #link("https://html5zombo.com/")[link look way more typical.]