Forum › How do I...?

Avoiding auto-linking

thugsb
I'm archiving a site, and I want to generate a PDF of the pages. Several of the pages have links in them, but I do NOT want these to be output as links, because many of them are likely to be broken. Instead, I want them to be output as text, and so I've set up my page to convert links to things like this:

<span class="url">http://www.google.com/</span>


However, when I'm running prince, the PDF that is output turns that into a link, so it is clickable. I don't want that. How do I stop it?

Another part of the problem is that many of the URLs are quite long and run onto multiple lines. When they do, the first part of the link is converted into a link, and the text on the second line is ignored. This is resulting in something like "http://ns.umich.edu/htdocs/releases/story.php?id=8618" linking to "http://ns.umich.edu/htdocs/" (broken) and "releases/story.php?id=8618" being relegated to the following line (unlinked).

Or is it the PDF viewer that is automatically linking the text, and not Prince?
mikeday
Prince will not generate a link for the span element, however some PDF viewers will try to be clever and interpret any text that looks like a URL as if it was a link.
Johann
I have the following (XSLT) expression in a code block:

<variable name="flashBaseAddress" select="($Configuration/FlashConfiguration/@baseAddress.dec,0)[1]"/>


The HTML is:
<!DOCTYPE html>
<html>
  <head>
    <title>Adobe auto-link</title>
    <style>
      pre { font: normal 10pt Courier, Consolas, fixed;  width:45em; white-space:pre-wrap; }
    </style>
  </head>
  <body>
    <pre>
{
  &lt;variable name="flashBaseAddress" select="($Configuration/FlashConfiguration/@baseAddress.dec,0)[1]"/&gt;
  ...
    </pre>
  </body>
</html>


Adobe software auto-detects the email address FlashConfiguration/@baseAddress.dec in the PDF.

To prevent the auto-detection I have inserted the CSS rule:

pre { -prince-text-replace: "@" "@\200a"; } /* add a hair space */


This works, but then there is a line break "@" - "baseAddress" in the attribute specifier @baseAddress.dec.

Does anyone know a better method, that does not split the attribute?


- - -
Johann

mikeday
This is actually really difficult (and really annoying!) as Acrobat applies this based on the text, so it's difficult to disable it without breaking the text so that selection and copying doesn't work as expected. I tried something like this:
<style>
span::before, span::after {
    content: " ";
    font-size: 20%
}
</style>
<pre>
username<span>@</span>domain.com
</pre>

But even with a fairly wide space the @ still ended up clickable!
Johann
Just found this on the internet:
The one dot leader character (U+2024) is useful for preventing URLs from turning into active, clickable links on social media and web platforms, or as a building block for horizontal leader lines in document layouts


Indeed, that solves my problem:
pre { -prince-text-replace: "." "\2024";


provided that nobody copies the code from the PDF :-)

- - -
Johann