Ask Your Question

How to eliminate URL text in conversion to pdf

asked 2021-11-29 03:37:07 +0200

holistone gravatar image

updated 2021-11-29 05:46:25 +0200

I have a simple single Markdown cell in a standard Sagemath 9.4 notebook on as shown below:

#### test URL links with conversion to pdf
This link **[Figure 9.1.4](** 
uses markdown **`[text]{(url)`** for the link.

which displays nicely as the following image description
in a browser. When I select the PRINT button, which performs the conversion to html I see: image description
in another tab in the browser.

The problem occurs when I do Print to pdf from any browser (Chrome, Firefox, Edge, Brave) on the displayed html tab, since the generated pdf file shows the active link among with the entire (explicit URL) as shown below. image description
The (explicit URL) also appears in the pdf if I run Save and Download as ... PDF or PDF via LaTeX.

If I use the Jupyter Classic Notebook Server, the resulting pdf does not contain the (explicit URL) after the [text] portion. A pdf from a similar CoLab notebook generated a year ago does not contain the (explicit URL) in the pdf versions.

I would like to find a way to eliminate the (explicit URL) part of the active links in the pdf conversion. Something appears to have changed in how Sagemath handles the conversion to html. Whereas the .ipynb file is less than 1KB, the .html file is 266KB. I am unable to attach the files since (apparently) only images are allowed as attachments.

edit retag flag offensive close merge delete


This is a cocalc issue, so please report to cocalc (or install Sage on your own machine).

tmonteil gravatar imagetmonteil ( 2021-11-29 15:10:29 +0200 )edit

It's not just a CoCalc issue. I also have Sagemath 9.3 (latest for Win10) installed and create pdf from File/Print Preview or create html from Download as/HTML also include (explicit URL) on the pdf.

holistone gravatar imageholistone ( 2021-11-29 17:30:34 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-11-30 19:31:41 +0200

holistone gravatar image

updated 2021-11-30 19:32:22 +0200

The source of the problem is described by William Stein in CoCalc GitHub as the presence of the 3 lines

  a[href]:after {
    content: " (" attr(href) ")";

in a .ccs file used by nbgrader. I believe he will provide an optimized solution for CoCalc and described a workaround, but this may not propagate to local installations.

On my local Win 10 Sagemath 9.3 installation, I found the offending 3 lines in 2 copies of style.min.css (around lines 202/4). Removing these lines solved the problem with my local installation. The same lines can be removed from an existing .html file to allow proper printing as pdf in any browser.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-11-29 03:37:07 +0200

Seen: 174 times

Last updated: Nov 30 '21