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

figure crossreference doesn't work when label has uppercase letters anywhere in it #9441

Open adknudson opened 5 months ago

adknudson commented 5 months ago

Bug description

Cross reference does not work when figure label has a uppercase letters in it.

Steps to reproduce

---
engine: julia
---

```{julia}
using CairoMakie

This is a reference to @fig-0x4a59ab6a-okay (works)

#| echo: fenced
#| label: fig-0x4a59ab6a-okay
#| fig-cap: "Just a caption"

xs = rand(50) * 2pi
ys = sin.(xs)
scatter(xs, ys)

This is a reference to @fig-0x7b2ada84-Okay (does not work)

#| echo: fenced
#| label: fig-0x7b2ada84-Okay
#| fig-cap: "Just a caption"

xs = rand(50) * 2pi
ys = sin.(xs)
scatter(xs, ys)

This is a reference to @fig-0xdd9b4a13-notbad (works)

#| echo: fenced
#| label: fig-0xdd9b4a13-notbad
#| fig-cap: "Just a caption"

xs = rand(50) * 2pi
ys = sin.(xs)
scatter(xs, ys)

This is a reference to @fig-0xdd9ca19d-nOtbad (does not work)

#| echo: fenced
#| label: fig-0xdd9ca19d-nOtbad
#| fig-cap: "Just a caption"

xs = rand(50) * 2pi
ys = sin.(xs)
scatter(xs, ys)

### Expected behavior

Any string sequence after `fig-` should be a valid identifier

### Actual behavior

Get missing reference in document.

### Your environment

- Windows_NT x64 10.0.19045
- VSCode v1.88.1

### Quarto check output

```bash
Quarto 1.5.29
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: 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.29
      Path: C:\Users\Alex\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: v2024.04
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\Alex\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2024

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

[>] Checking Python 3 installation....OK
      Version: 3.12.3
      Path: C:/Python312/python.exe
      Jupyter: 5.7.2
      Kernels: python3

(/) Checking Jupyter engine render....2024-04-21 18:13:48,874 - traitlets - WARNING - Kernelspec name python3 cannot be found!
2024-04-21 18:13:48,874 - traitlets - ERROR - No such kernel named python3
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\jupyter_client\manager.py", line 87, in wrapper
    out = await method(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\jupyter_client\manager.py", line 435, in _async_start_kernel    
    kernel_cmd, kw = await self._async_pre_start_kernel(**kw)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\jupyter_client\manager.py", line 397, in _async_pre_start_kernel
    self.kernel_spec,
    ^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\jupyter_client\manager.py", line 195, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\jupyter_client\kernelspec.py", line 285, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named python3

No such kernel named python3
[>] Checking Jupyter engine render....OK
adknudson commented 5 months ago

Possibly related to #587

mcanouil commented 5 months ago

This seems to be an issue of case being insensitive for engine Jupyter and Julia:

---
title: "Quarto Playground"
format: html
---

@fig-0x7b2ada84-okay (all lower case works)

```{python}
#| label: fig-0x7b2ada84-Okay
#| fig-cap: "Just a caption"
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = np.sin(x)

plt.plot(x, y)

Workaround: use fenced div syntax:

````qmd
---
format: html
engine: julia
---

This is a reference to @fig-0x7b2ada84-Okay (does not work)

::: {#fig-0x7b2ada84-Okay}

```{julia}
#| echo: fenced
xs = rand(50) * 2pi
ys = sin.(xs)
scatter(xs, ys)

Just a caption

:::

cscheid commented 3 months ago

The keep-ipynb output has an uppercase identifier

  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fig-0x7b2ada84-Okay",
   "metadata": {},

But the keep-md output has a lowercase identifier:

::: {.cell-output .cell-output-display}
![Just a caption](9441_files/figure-html/fig-0x7b2ada84-okay-output-1.png){#fig-0x7b2ada84-okay width=590 height=411}
:::

That means that somewhere in the ipynb to jupyter conversion, Quarto is explicitly converting the ids to lower case.

I think we should mandate that such identifiers be lowercase, and issue warnings on the relevant inputs.