quarto-dev / quarto-dev/quarto

Visual Editor strips cross-reference ID from inline table caption

Open
#977 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug description

Switching a .qmd from source to the Visual Editor (and back) strips the cross-reference ID from a table caption written in the inline form : Caption {#tbl-one}.
After the round-trip the caption becomes : Caption and @tbl-one no longer resolves.

The equivalent div form ::: {#tbl-two} ... ::: is preserved, so the bug is specific to the inline caption attribute syntax.

Originally reported in https://github.com/quarto-dev/quarto-cli/discussions/14514.

Steps to reproduce
  1. Create issue.qmd:

    ---
    title: About
    format: html
    ---
    
    @tbl-one and @tbl-two
    
    | A | B | C |
    |---|---|---|
    | 1 | 2 | 3 |
    
    : Caption {#tbl-one}
    
    ::: {#tbl-two}
    
    | A | B | C |
    |---|---|---|
    | 1 | 2 | 3 |
    
    Caption
    
    :::
    
  2. Open in the Visual Editor, make any edit (or just toggle and save).

  3. Switch back to source.

Actual behavior

The {#tbl-one} attribute is removed from the caption:

| A   | B   | C   |
|-----|-----|-----|
| 1   | 2   | 3   |

: Caption

@tbl-one renders as ?@tbl-one and the cross-reference is broken.
The {#tbl-two} div form survives the round-trip unchanged.

Expected behavior

The Visual Editor should preserve {#tbl-one} on the table caption across round-trips, matching its behaviour for div-wrapped tables.

Your environment

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 round-trip with the provided issue.qmd in the Visual Editor, comparing the inline caption form with the preserved div form. Trace the editor's source serialization for table captions and verify that switching views preserves {#tbl-one} and resolves @tbl-one after saving.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.