quarto-dev / quarto-dev/quarto-cli
Multi-line alternative text doesn't work for python cells
Open
@cscheid is already working on this.
Since Jul 3, 2024.
bug
engines-jupyter
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Quarto version 1.5.52.
The two cells in the following document should produce the same output, but they don't. I've used echo: fenced to show the result clearly.
---
format: html
execute:
echo: fenced
---
```{python}
#| label: import-pkgs
import numpy as np
import matplotlib.pyplot as plt
```
```{python}
#| label: fig-single-line-alt
#| fig-alt: Looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg alternative text string that would be better as a multi-line entry.
#| fig-cap: Figure caption
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
subplot_kw = {'projection': 'polar'}
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```
```{python}
#| label: fig-multi-line-alt
#| fig-alt: |
#| Looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg alternative
#| text string that would be better as a multi-line entry
#| fig-cap: Figure caption
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
subplot_kw = {'projection': 'polar'}
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```
See the result below.
The issues are:
- Alt text not processed properly for the multi-line case.
- Figure caption also not processed properly even though nothing changed in how it's defined.
- Figure sizes are different (though this might partially be due to no caption/figure environment).
Multi-line alt text works in R, see below.
Code from the above image included below for reproducibility.
---
format: html
---
```{r}
#| label: fig-single-line-alt
#| fig-alt: Looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg alternative text string that would be better as a multi-line entry.
#| fig-cap: Figure caption
plot(cars)
```
```{r}
#| label: fig-multi-line-alt
#| fig-alt: |
#| Looooooooooooooooooooonnnngggg looooooooooooooooooooonnnngggg
#| looooooooooooooooooooonnnngggg alternative
#| text string that would be better as a multi-line entry.
#| fig-cap: Figure caption
plot(cars)
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.