Dollar signs in plotly trace names cause render issues when LaTeX is used elsewhere

Open
#11,078 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, latex, r
Domain
web-dev

Research direction

Start by rendering the supplied Quarto document with the listed Quarto versions and compare the output with the documented workarounds. Trace how LaTeX dollar signs and Plotly trace names appear in the generated HTML, then verify that the document and figures render normally without requiring those workarounds.

Written by the indexing model from the issue text.

Description

bug plotly
Bug description

I noticed documents do not render as expected when they contain $\LaTeX$ dollar signs and plotly figures that have dollar signs in their trace names. In my case, each trace represents a price range.

Steps to reproduce

The plotly figure in this document does not render properly.

---
title: "Test Doc"
format: html
---

$R^2$

```{r}
#| code-fold: true

x <- c(1:100)
trace_0 <- rnorm(100, mean = 5)
trace_1 <- rnorm(100, mean = 0)

data <- data.frame(x, trace_0, trace_1)

plotly::plot_ly(data, type = "scatter", mode = "lines") |>
	plotly::add_trace(x = ~x, y = ~trace_0, name = "$100-$200") |>
	plotly::add_trace(x = ~x, y = ~trace_1, name = "$200-$300")
```
Expected behavior

That the document and plotly figures therein would render properly.

The document does render as expected if:

  • The $\LaTeX$ equation is removed
  • One of the dollar signs in each trace name is removed
  • At least one of the dollar signs in each trace name is replaced with the corresponding HTML entity code (&#36;)

I include these workarounds for anyone else who has trouble with this, but I would expected these symbols to be handled as necessary.

Image

Actual behavior

The plotly figure is very small and all you can see is part of the legend.

Image

Your environment

Positron Version: 2024.10.0 (Universal) build 14
Code - OSS Version: 1.93.0
Commit: 901ab5d11d694212d32e53b97f771c5d601e428e
Date: 2024-10-09T15:26:55.363Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

Quarto check output
Quarto 1.6.26
[✓] 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.6.26
      Path: /Applications/quarto/bin

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

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

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

[✓] Checking Python 3 installation....OK
      Version: 3.9.6
      Path: /Users/jeffkeller/git/test/renv/python/virtualenvs/renv-python-3.9/bin/python
      Jupyter: 5.7.2
      Kernels: python3

(|) Checking Jupyter engine render....Traceback (most recent call last):
  File "/Applications/quarto/share/jupyter/jupyter.py", line 21, in <module>
    from notebook import notebook_execute, RestartKernel
  File "/Applications/quarto/share/jupyter/notebook.py", line 15, in <module>
    from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
There is a requirements.txt file in this directory. Is this for a venv that you need to restore?

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

I can reproduce this issue in Quarto 1.5.56, 1.5.57, and 1.6.26 (pre-release)

Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quarto-dev/quarto-cli

All issues in quarto-dev/quarto-cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.