How to prevent automatic hyperlinking of URLs?

How can I prevent text starting with “https://” from being interpreted as a hyperlink? I tried #raw() but that didn’t work.

I don’t mind if the text is styled like a link but I don’t want the PDF reader to present it as clickable. The link is intentionally just a placeholder and won’t work so clicking on it is just confusing to the reader.

Thanks in advance!

Hi @bfallik ,

Not related Typst specific, I would like to point out that in my experience, as you may already know, some PDF readers render plain text URLs such as http:// automatically clickable as links.

For example, if you look at this PDF file that I have just created:
todelete.pdf (30.0 KB)

  • The first line contains only text.
  • The second line contains two URLs.

image

However, I’ve tried opening it with various PDF readers and the result differs depending on the PDF reader (and selected user preferences). Some PDF readers will try to help and make the URLs clickable, even with the plain text example on the first line. Just hover over the text with the mouse while you do your trials. Others readers will just disregard.

Hope this helps in the search of the solution with the Typst related question.

1 Like

Interesting. I half suspected that this was coming from the PDF reader and not the PDF itself. Thx for confirming.

Watch out. Typst does automatically create a clickable hyperlink from markup such as:

This will be http://clickable.com

Is there a way to prevent that?

From this: How to prevent DOI/URL in bibliography from becoming a #link? - #2 by PgBiel, you can try:

#show link: it => it.body
This will be http://non-clickable.com unless the PDF reader creates a smart link.
1 Like

The link is intentionally just a placeholder

If you only have one URL, then quoting it as str might be easier.

#"https://example.com"

You could test it with HTML export:

$ echo 'https://example.com' | typst compile - - --format html --features html
<!DOCTYPE html>
<html>
  <head>…</head>
  <body>
    <p><a href="https://example.com">https://example.com</a></p>
  </body>
</html>

$ echo '#"https://example.com"' | typst compile - - --format html --features html
<!DOCTYPE html>
<html>
  <head>…</head>
  <body>
    <p>https://example.com</p>
  </body>
</html>
3 Likes

Thanks. The #"..." syntax works perfectly.

1 Like