Skip to content

Incompatibility of KaTeX math and Tippy popups on cross references #12259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
benkeks opened this issue Mar 10, 2025 · 0 comments · May be fixed by #12288
Open

Incompatibility of KaTeX math and Tippy popups on cross references #12259

benkeks opened this issue Mar 10, 2025 · 0 comments · May be fixed by #12288
Labels
bug Something isn't working math any issue related to math support in specific formats

Comments

@benkeks
Copy link

benkeks commented Mar 10, 2025

Bug description

When using KaTeX as HTML math method, the Tippy.js tooltip popups on cross references do not work if the preview snippet contains math.

Note: The problem only appears with references to items of the same document. In a multi-file book project, the references to items in other chapters do render correctly.

Steps to reproduce

---
title: "Reproducible Quarto Document"
format: html
html-math-method: katex
---

:::{#thm-with-math}
### Theorem with math

Text with math $\mathcal P (\mathbb N) ≠ \varnothing$.
:::

:::{#thm-without-math}
### Theorem without math

Just text!
:::

Reference to @thm-with-math. (Popup does not render correctly)

Reference to @thm-without-math. (Popup does render.)
  • Preview (or render) HTML.
  • Hover over the reference to Theorem 1.

Actual behavior

An empty popup opens.

Image

and the browser console reports:

katex.min.js:1 Uncaught TypeError: KaTeX can only parse string typed expression
    at Gn (katex.min.js:1:274914)
    at Xn (katex.min.js:1:275946)
    at Object.Un [as render] (katex.min.js:1:275385)
    at Object.typesetMath ((index):67:22)
    at processXRef ((index):310:23)
    at Object.cellAttr [as onTrigger] ((index):335:26)
    at ae (tippy.umd.min.js:1:9810)
    at Le (tippy.umd.min.js:1:14548)
    at HTMLAnchorElement.ye (tippy.umd.min.js:1:12326)

Expected behavior

A popup displaying Theorem 1 is shown.

Your environment

  • Debian 12/Testing
  • Chome 133.0.6943.141 (Official Build) (64-bit)

Quarto check output

Quarto 1.7.15
[✓] Checking environment information...
Quarto cache location: /home/ben/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.4.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.46.3: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.7.15
Path: /opt/quarto/bin

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

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

[✓] Checking Chrome Headless....................OK
Using: Chrome found on system
Path: /usr/bin/google-chrome
Source: PATH

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

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

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

[✓] Checking R installation...........(None)

  Unable to locate an installed version of R.
  Install R from https://cloud.r-project.org/
@benkeks benkeks added the bug Something isn't working label Mar 10, 2025
@mcanouil mcanouil added the math any issue related to math support in specific formats label Mar 10, 2025
benkeks added a commit to benkeks/quarto-cli that referenced this issue Mar 13, 2025
As described in quarto-dev#12259, Tippy.js popups on crossrefs failed if the
previewed entity contained KaTeX math elements. This seems to be
due to double rendering where the `data` attribute is unset on
the second pass. Just skipping the invocation of the KaTeX renderer
in these instances solves the issue.
@benkeks benkeks linked a pull request Mar 13, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working math any issue related to math support in specific formats
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants