A list-table cell holding a paragraph is written tight and re-reads as plain

Open
#1,158 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

The issue identifies write_list_table as the writer that loses the distinction between Para and Plain; start by locating that function and comparing its cell separators with list_is_tight and the list writers. Reproduce the round trip with the supplied input using cargo run --bin pampa, then check that the x cell remains Para after writing and reading. No test file is named in the issue.

Written by the indexing model from the issue text.

Description

Since the CommonMark loose/tight change (370123a8aefb144ea32c8443c2ee0e1b32309e7d, #1098), a list-table row whose cells are separated by a blank line reads with Para cells. write_list_table writes a cell's first Plain and Para identically and never puts a blank line between cells, so the row comes back tight and the Para cell re-reads as Plain. Ordinary bullet lists keep the distinction (list_is_tight), so the loss is specific to the list-table cell writer.

Input:

$ printf -- '::: {.list-table}\n\n* * a\n  * b\n\n* * x\n\n  * ```\n    code\n    ```\n\n:::\n'
::: {.list-table}

* * a
  * b

* * x

  * ```
    code
    ```

:::

Reader (the x cell is a Para):

$ printf -- '...' | cargo run --bin pampa -- 2>&1
[ Table ( "" , [] , [] ) (Caption Nothing []) [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] (TableHead ( "" , [] , [] ) [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "a"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "b"]] ] ]) [TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Para [Str "x"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [CodeBlock ( "" , [] , [] ) "code"] ] ]] (TableFoot ( "" , [] , [] ) [] ) ]

Writer (no blank line between the x cell and the code cell):

$ printf -- '...' | cargo run --bin pampa -- -t qmd 2>&1
::: {.list-table}

* - a
  - b
* - x
  - ```
    code
    ```
:::

Round trip (the x cell is now Plain):

$ printf -- '...' | cargo run --bin pampa -- -t qmd 2>/dev/null | cargo run --bin pampa -- 2>&1
[ Table ( "" , [] , [] ) (Caption Nothing []) [(AlignDefault, ColWidthDefault), (AlignDefault, ColWidthDefault)] (TableHead ( "" , [] , [] ) [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "a"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "b"]] ] ]) [TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [Row ( "" , [] , [] ) [Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "x"]] , Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [CodeBlock ( "" , [] , [] ) "code"] ] ]] (TableFoot ( "" , [] , [] ) [] ) ]

The only difference between the two reads:

- Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Para [Str "x"]]
+ Cell ( "" , [] , [] ) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "x"]]

Related: #1098 introduced the looseness rule that exposes this. #1151 fixes a sibling writer round trip from the same change (adjacent lists inside a list item) but only touches write_bulletlist / write_orderedlist and the raw-block separator, not write_list_table, so it does not cover this case. #174 was the same Para to Plain symptom for ordinary bullet lists.

In the wild (quarto-web grid tables with a code-block cell; qmd-syntax-helper convert -r grid-tables turns them into list tables with blank-line-separated cells):

Dominant language
Rust
Stars
302
Forks
22
Avg merge
5h 2m
Merged PRs (30d)
213

Getting set up

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/q2

All issues in quarto-dev/q2

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.