quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.82k stars 309 forks source link

HTML link rendering issue with parentheses in DOI links on GitHub Pages #9759

Closed TomBener closed 4 months ago

TomBener commented 4 months ago

Bug description

I am experiencing an issue with how HTML links containing parentheses are rendered when using the link-external-icon and link-external-newwindow options in Quarto. The HTML snippet generated locally is correct, but when the page is deployed on GitHub Pages or other online servers, the link structure changes unexpectedly.

Steps to reproduce

  1. Configure Quarto with the following YAML options:
format:
  html:
    link-external-icon: true
    link-external-newwindow: true
  1. Generate a HTML file locally with the following content:
Gruffudd P, 1995. Remaking Wales: Nation-Building and the Geographical Imagination, 1925–1950[J/OL]. Political Geography, 14(3): 219–239. DOI: <a href="https://doi.org/10.1016/0962-6298(95)93185-L">10.1016/0962-6298(95)93185-L</a>.
  1. Deploy the HTML file to GitHub Pages.
  2. Inspect the HTML output using Chrome's "Inspect Element" feature.

Expected behavior

The link should appear as follows:

Gruffudd P, 1995. Remaking Wales: Nation-Building and the Geographical Imagination, 1925–1950[J/OL]. Political Geography, 14(3): 219–239. DOI: <a href="https://doi.org/10.1016/0962-6298(95)93185-L" target="_blank" rel="noopener" class="external">10.1016/0962-6298(95)93185-L</a>.

Actual behavior

The link is rendered as follows:

Gruffudd P, 1995. Remaking Wales: Nation-Building and the Geographical Imagination, 1925–1950[J/OL]. Political Geography, 14(3): 219–239. DOI: <a href="https://doi.org/10.1016/0962-6298(95" target="_blank" rel="noopener" class="external">10.1016/0962-6298(95</a>)93185-L.

Additional Information:

The issue seems to be caused by the presence of parentheses within the DOI link. Links without parentheses are rendered correctly. In comparison, generating the same html file via Pandoc directly doesn't have this issue. I suspect the problem lies in the specific libraries Quarto is using.

The bib file is as follows:

@article{gruffudd1995,
  title = {Remaking {{Wales}}: {{Nation-Building}} and the {{Geographical Imagination}}, 1925--1950},
  shorttitle = {Remaking {{Wales}}},
  author = {Gruffudd, Pyrs},
  date = {1995-04-01},
  journaltitle = {Political Geography},
  volume = {14},
  number = {3},
  pages = {219--239},
  doi = {10.1016/0962-6298(95)93185-L}
}

Your environment

Quarto check output

Details ``` Quarto 1.5.39 [✓] Checking versions of quarto binary dependencies... Pandoc version 3.2.0: OK Dart Sass version 1.70.0: OK Deno version 1.41.0: OK Typst version 0.11.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.5.39 Path: /Applications/quarto/bin [✓] Checking tools....................OK TinyTeX: v2024.05 Chromium: (not installed) [✓] Checking LaTeX....................OK Using: TinyTex Path: /Users/username/Library/TinyTeX/bin/universal-darwin Version: 2024 [✓] Checking basic markdown render....OK [✓] Checking Python 3 installation....OK Version: 3.10.10 Path: /Users/username/.pyenv/versions/3.10.10/bin/python3 Jupyter: 5.7.2 Kernels: python3 [✓] Checking Jupyter engine render....OK [✓] Checking R installation...........OK Version: 4.4.0 Path: /opt/homebrew/Cellar/r/4.4.0_1/lib/R LibPaths: - /Users/username/.R/packages - /opt/homebrew/lib/R/4.4/site-library - /opt/homebrew/Cellar/r/4.4.0_1/lib/R/library knitr: 1.46 rmarkdown: 2.26 [✓] Checking Knitr engine render......OK ```
cderv commented 4 months ago

I tried with this document

---
title: "Presentation"
format:
  html:
    link-external-icon: true
    link-external-newwindow: true
---

# Using HTML unmarked

Gruffudd P, 1995. Remaking Wales: Nation-Building and the Geographical Imagination, 1925–1950[J/OL]. Political Geography, 14(3): 219–239. DOI: <a href="https://doi.org/10.1016/0962-6298(95)93185-L">10.1016/0962-6298(95)93185-L</a>.

# Using HTML marked

Gruffudd P, 1995. Remaking Wales: Nation-Building and the Geographical Imagination, 1925–1950[J/OL]. Political Geography, 14(3): 219–239. DOI: `<a href="https://doi.org/10.1016/0962-6298(95)93185-L">10.1016/0962-6298(95)93185-L</a>`{=html}.

# Using Markdown 

Gruffudd P, 1995. Remaking Wales: Nation-Building and the Geographical Imagination, 1925–1950[J/OL]. Political Geography, 14(3): 219–239. DOI: [10.1016/0962-6298(95)93185-L](https://doi.org/10.1016/0962-6298(95)93185-L)

And I published it to quartopub to check : https://cderv.quarto.pub/html-test/

image

All links are correctly formated and works.

So it seems either it is link to some github pages processing (how did you deploy it ?) or this is link to your specific content ?

Can you create a reproducible example as a github repository, and deploy your project to gh-pages in this repository ?

This way we can check live example, and clone it and investigate if needed.

Thank you !

TomBener commented 4 months ago

Thanks for your testing!

I opened your deployed page and the link worked not correctly. I have tested on both Chrome and Safari.

CleanShot 2024-05-24 at 17 32 32@2x

CleanShot 2024-05-24 at 17 32 55@2x

I think this is the problem of my browsers.

Thanks again. I'll investigate further.

TomBener commented 4 months ago

It works well on iOS Safari.

IMG_0509

mcanouil commented 4 months ago

I cannot reproduce your issue:

Safari 17.5Brave 1.66.110 (Chromium: 125.0.6422.60)
image image
cderv commented 4 months ago

It works also ok on Chrome for me, and also Edge, Firefox. So it seems something in your browser environment makes this not work.

You should try in private windows, with all extensions deactivated in case one of them is applying some processing on those links. EDIT: Which it seems you already did.

Can you check the source code from the page you have? (Right click + See source code or something like that) It should be correct, which would then lead to a processing somehow on your environment. Not sure what...

TomBener commented 4 months ago

The source code of the page is also broken in Chrome 125.0.6422.113, as well as Safari 17.5. I also tested on Arc and Firefox, all the same. But I switched to another Mac, the links displayed as expected, that's really weird…

CleanShot 2024-05-24 at 20 52 48@2x

CleanShot 2024-05-24 at 20 54 45@2x

TomBener commented 4 months ago

FINALLY, I figured out the cause! It is because I have installed a userscript to manipulate some link rules. Disabling it would fix the link issue above. I'll remove this userscript immediately. Thanks for your patient help @cderv @mcanouil