quarto-dev / quarto-dev/quarto

Quarto visual mode / source mode switching breaks equation block formatting and syntax highlighting

Open
#1,047 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug visual-editor
Dominant language
TypeScript
Stars
645
Forks
62
Avg merge
17h 42m
Merged PRs (30d)
13

Description

Bug description

👋hello! This issue was originally posted at https://github.com/posit-dev/positron/issues/14763#issue-4838651653, and is reposted here at the request of @juliasilge .

When switching between visual mode and source mode in a Quarto .qmd document, the editor reformats multi-line equation blocks

$$
equation
$$

into single-line form

$$equation$$

, which causes two related bugs:

Bug 1 — Cross-reference label malformation

After a visual→source mode switch, a properly formatted numbered equation like:

$$
y_i = \alpha + \sum_{j=1}^{p} \beta_j x_{ij} + \varepsilon_i
$$ {#eq-liner-model}

is reformatted into:

$$\text{equation}$$
 {#eq-a-error-format}

The label {#eq-a-error-format} is placed on a new line with a leading space, making it unrecognizable to the Quarto cross-reference engine. Rendering the document produces:

Unable to resolve crossref @eq-a-error-format

Bug 2 — Lost syntax highlighting (gray background)

A correctly formatted single-line numbered equation:

$$(\hat{\alpha}, \hat{\boldsymbol{\beta}}) = \arg\min \left\{ \sum_{i=1}^{N} \left(y_i - \alpha - \sum_{j=1}^{p} \beta_j x_{ij}\right)^2 \right\} \quad \text{subject to} \quad \sum_{j=1}^{p} |\beta_j| \leq t$$ {#eq-lasso}

renders correctly and cross-references work, but the equation block itself is not wrapped in the usual gray background box. Moreover, any R code blocks that follow this equation also lose their gray background.

Expected behavior:

Switching between visual and source mode should preserve the original multi-line equation block structure.

The {#eq-label} syntax should remain on the same line as the closing $$.

All code blocks should consistently display the gray background regardless of preceding equation formatting.

I have checked https://github.com/posit-dev/positron/discussions/8684#discussion-8640338. It seems to be related to the issue I am experiencing, but it looks like it has not been properly fixed yet.

My Quarto version is 1.9.38 and my Positron version is 2026.07.0.

Attachments:

Image Image Image

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start by reproducing the visual/source mode switch in a Quarto .qmd document using the multi-line equation and {#eq-label} examples from the report. Trace the visual/source mode entry point that reformats equation blocks, then verify that the closing $$ and label remain together, cross-references resolve, and following R code blocks retain their gray background.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.