Skip to content

Citation hover popup uses unsorted data-cites order instead of rendered CSL order #13535

@TomBener

Description

@TomBener

Description

When rendering citations with author-date CSL styles in Quarto (HTML output), the in-text citation cluster is correctly sorted according to the CSL <sort> rules (e.g., alphabetical by author). However, the hover popup (the tooltip showing full reference entries) displays items in the original citation order from Markdown, not the sorted display order.

This produces inconsistent and confusing results: the text and the tooltip list the same references in different orders.

Example

Source Markdown

[@lipman1997; @dikotter2015; @gladney2004]

Expected output (APA / author-date):

Text (correct):

(Dikötter, 2015; Gladney, 2004; Lipman, 1997)

Hover popup (expected to match text):

Dikötter F (2015)…
Gladney DC (2004)…
Lipman JN (1997)…

Actual hover popup (unsorted):

Lipman JN (1997)…
Dikötter F (2015)…
Gladney DC (2004)…

Diagnosis

Quarto builds citation tooltips from the data-cites attribute in the HTML:

<span class="citation" data-cites="lipman1997 dikotter2015 gladney2004"></span>

Pandoc correctly sorts the inline text, but Quarto’s tooltip logic reads data-cites as originally typed, not in the rendered order.
Thus, the popup order diverges from the visible citation order whenever the CSL style defines a <sort>.

Expected Behavior

The hover popup should respect the sorted CSL order—i.e., the same order that appears in the rendered citation text.

Steps to Reproduce

  1. Use any author–date CSL style that defines a <citation><sort> (e.g. apa.csl).
  2. Create a .qmd file with the example citation above.
  3. Render to HTML (quarto render example.qmd).
  4. Hover over the citation cluster: the popup order differs from the visible order.

Environment

$ quarto check

Quarto 1.9.3
[✓] Checking environment information...
      Quarto cache location: /Users/username/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.6.3: OK
      Dart Sass version 1.87.0: OK
      NOTE: Deno version 2.4.5 does not strictly match 2.3.1 and strict checking is enabled. Please use 2.3.1.
      Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.9.3
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2025.10
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/username/Library/TinyTeX/bin/universal-darwin
      Version: 2025

[✓] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
      Source: MacOS known location

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.2
      Path: /Users/username/.pyenv/versions/3.12.2/bin/python3
      Jupyter: 5.8.1
      Kernels: python3

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

[✓] Checking R installation...........OK
      Version: 4.5.1
      Path: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources
      LibPaths:
        - /Users/username/.R/packages
        - /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
      knitr: 1.49
      rmarkdown: 2.29

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-reproIssues that are blocked until reporter provides an adequate reproduction

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions