quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
280 stars 19 forks source link

Automatic footnote identifier prefixing normalizes filenames imperfectly #424

Open salim-b opened 2 months ago

salim-b commented 2 months ago

Bug description

RStudio’s Markdown canonicalization, which is provided by Quarto, adds a normalized version of the edited file's name as footnote (and other) identifiers via Pandoc's --id-prefix CLI argument[^s]. This is a good thing, in principle.

But the filename normalization is very imperfect, I recently discovered. It should be extended to also normalize (i.e. remove) the special characters it currently doesn't touch. See below for an example (note that it is by no means exhaustive, I just typed special characters until I lost interest).

[^s]: I think this is the place where Quarto passes the ID prefix value on to Pandoc.

Steps to reproduce

  1. Create a text file named such.a <[{(weird)}]>|@#§°\&%$£:;*+"´`'~=filename - – — RIGHT?!.md (this is a totally valid filename on Linux).

  2. Paste some Markdown content including at least one footnote in it.

  3. Open the file in RStudio and click on Visual editor mode, then switch back to Source editor mode and look at the first footnote identifier.

Expected behavior

Quarto should normalize the above filename to the (footnote) ID prefix:

[^such.a-weirdfilename-----right-1]

Actual behavior

Quarto actually normalizes the above filename to the (footnote) ID prefix:

[^such.a-(weird§°£´filename---–-—-right-1]

Your environment

Quarto check output

Quarto 1.4.553
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.553
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /home/salim/.local/bin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.12
      Path: /usr/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /usr/lib/R
      LibPaths:
        - /home/salim/.software/managed/r
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: 1.46
      rmarkdown: 2.26

[✓] Checking Knitr engine render......OK

Related