1

I am using weasyprint 56.1 with django-weasyprint 2.1.0, with vanilla settings.

When my HTML contains an ordinary hyperlink of the form

<a href="https://example.com">my link text</a>

I want weasyprint to generate PDF that looks like

my link text

and where that text is a hyperlink to https://example.com.
However, what I get instead is the following format:

my link text (https://example.com)

where both parts are hyperlinked. The link is correct and works, but I do not want the URL to show.

I could not find anything about this in the weasyprint documentation.
I just spent an hour in the weasyprint source code trying to find the spot where this formatting happens, but to no avail.

What logic is responsible for this formatting and how can I change it?

Lutz Prechelt
  • 36,608
  • 11
  • 63
  • 88

2 Answers2

1

This isn't an answer to the question you asked, but I had the same issue, and then realized that in my CSS I had this artifact from a template:

a[href]:after {
  content: " (" attr(href) ")";
}
  • Not directly an answer, but very helpful. I found a CSS declaration within weasyprint that says `a[href] { -weasy-link: attr(href); }`. The `-weasy-` pseudo-property prefix triggers custom logic within weasyprint's built-in CSS processing that I have not yet been able to understand -- but likely the above rule is where I need to interfere. Thanks! – Lutz Prechelt Sep 21 '22 at 12:37
0

Thank you for the tip Caleb!

I had the same issue and solved it with the following line in my pdf.css:

a[href]:after {
  content: " ";
}
Mahmut ARIKAN
  • 615
  • 8
  • 7