quarto-dev / quarto-cli

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

image-placeholder ignored when more than one listing #9845

Closed Nesper94 closed 2 months ago

Nesper94 commented 2 months ago

Bug description

If more than one listing is created for a page, and if the "image-placeholder" option is used for the listings, the image used as placeholder in all listings is the one for the first listing. Sometimes no image placeholder is shown, however I could not get a reproducible example of this case.

This issue may be related to #6447 and it's present in Quarto version 1.4.554.

Steps to reproduce

Create a project and example folders and files:

quarto create project website mysite
cd mysite
mkdir posts tutorials things

Here is the project structure:

.
├── about.qmd
├── index.qmd
├── posts
│   └── post1.qmd
├── _quarto.yml
├── styles.css
├── things
│   └── thing1.qmd
└── tutorials
    └── tutorial1.qmd

Edit index.qmd so that it contains several listings using image-placeholder:

---
title: "Mysite"
listing:
  - id: posts
    contents: posts/*.qmd
    image-placeholder: https://quarto.org/quarto.png

  - id: tutorials
    contents: tutorials/*.qmd
    image-placeholder: https://quarto.org/docs/authoring/images/html-figure.png

  - id: things
    contents: things/*.qmd
    image-placeholder: https://quarto.org/docs/authoring/images/elephant-subfigures.png
---

:::{#posts}
:::

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.

:::{#tutorials}
:::

Create example files: posts/post1.qmd:

---
title: 'Post 1'
---

Hello

tutorials/tutorial1.qmd:

---
title: 'Tutorial'
---

# My tutorial

things/thing1.qmd:

---
title: 'A thing'
---

# This is an example

Expected behavior

Each listing element should display its corresponding image placeholder.

Actual behavior

All listings display the image placeholder from the first listing:

bug

Your environment

IDE: VIM - Vi IMproved 8.2 Operating system: Linux Xubuntu 22.04.3 LTS

Quarto check output

No response

cderv commented 2 months ago

Currently, I believe with support only a single image placeholder for all listings on a single page.

We would need to adapt to use the placeholder from each listings.

https://github.com/quarto-dev/quarto-cli/blob/6d09c3a6978aa03298f78ade9b08e447dbef38d4/src/project/types/website/listing/website-listing-read.ts#L334-L338

https://github.com/quarto-dev/quarto-cli/blob/6d09c3a6978aa03298f78ade9b08e447dbef38d4/src/project/types/website/listing/website-listing-read.ts#L438-L446