quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.92k stars 322 forks source link

Multiline / linebreak in tbl-cap is not supported #11290

Open winniehell opened 4 days ago

winniehell commented 4 days ago

Bug description

The second table does not render correctly:

---
title: "Empty"
engine: jupyter
---

```{python}
#| label: tbl-test1
#| tbl-cap: Test1

import pandas as pd

pd.DataFrame(dict(x=[10,20,30]))
#| label: tbl-test2
#| tbl-cap: >
#|   Test2

import pandas as pd

pd.DataFrame(dict(x=[10,20,30]))
#| label: fig-test3
#| fig-cap: >
#|   Test3

import pandas as pd

pd.DataFrame(dict(x=[10,20,30]))

### Steps to reproduce

render the above example to HTML or PDF using the Jupyter engine

…or look at https://github.com/winniehell/quarto-playground/blob/9b084a0f9339394c0687bf7d0cc58eb215ce70be/test-book/_book/test-book.pdf (you will need to scroll down)

### Expected behavior

second table is rendered with caption

### Actual behavior

multiline caption / linebreak causes problem (only for table, not for figure)

![screenshot of the broken table caption](https://github.com/user-attachments/assets/32d90363-69f6-469e-96a0-446dc15603de)

also this warning is shown:

WARNING (~/quarto-cli/src/resources/filters/./normalize/astpipeline.lua:14) The following string was found in the document: ::: This string was found in a block element with the following content:

::: {#tbl-test2 .cell tbl-cap=’

This usually indicates a problem with a fenced div in the document. Please check the document for errors. WARNING (~/quarto-cli/src/resources/filters/./normalize/astpipeline.lua:14) The following string was found in the document: ::: This string was found in a block element with the following content:

:::

This usually indicates a problem with a fenced div in the document. Please check the document for errors.


### Your environment

$ nixos-version 
24.05.20241012.a3f9ad6 (Uakari)

### Quarto check output

<details>
<summary>quarto check</summary>

Quarto 99.9.9 [✓] Checking environment information... Quarto cache location: ~/.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: 99.9.9 commit: 80bf6b5848bf644de3a4d59e26b5eb067375986a Path: ~/quarto-cli/package/dist/bin

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

[✓] Checking LaTeX....................OK Using: Installation From Path Path: /run/current-system/sw/bin Version: undefined

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

[✓] Checking Python 3 installation....OK Version: 3.12.5 Path: ~/quarto-playground/.venv/bin/python3 Jupyter: 5.7.2 Kernels: python3

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

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

  Unable to locate an installed version of R.
  Install R from https://cloud.r-project.org/

</details>
winniehell commented 4 days ago

side note:

#| tbl-cap: "First\nSecond"

also doesn't work

mcanouil commented 4 days ago

Thanks, I can reproduce. The issue is that the entry is not read properly at all. For instance, | or > should not lead to a line break before the first word.

InputOutput
````qmd --- title: "Empty" format: html --- ```{python} #| label: tbl-test2 #| tbl-cap: | #| Test2 import pandas as pd pd.DataFrame(dict(x=[10,20,30])) ``` ```` ![Image](https://github.com/user-attachments/assets/841e8beb-6369-4677-990f-039809832f98)

Workaround: use cross-ref div.

---
title: "Empty"
engine: jupyter
format: html
---

::: {#tbl-test2}

```{python}
import pandas as pd

pd.DataFrame(dict(x=[10,20,30]))

Title using markdown
on two lines :::