quarto-dev / quarto-dev/quarto-cli

Single file in `contents:` does not render

Open
#9,131 5 comments 0 reactions 1 assignee View on GitHub

@cscheid is already working on this.

Since Jun 5, 2024.

bug websites
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

I don't think this is the most important "bug" to fix; but I figured I would flag. When using a single file in the contents of a section (see example below), that file does not render.

It can be fixed by using a item with - file: about.qmd, but took me about ~30 mins to debug. The reason I bring up the bug at all is that yaml::write_yaml will render a single list item in contents in the form that causes bugs (see example below). This bug impacts the altdoc package (cc @etiennebacher)

Reprex:

  1. Run quarto create project website reprex to create simple website.
  2. Change _quarto.yml to:
project:
  type: website

website:
  title: "reprex"
  sidebar:
    collapse-level: 1
    style: docked
    contents:
      - text: Home
        file: index.qmd
      - section: Section Header
        contents: about.qmd

format:
  html:
    theme: cosmo
    css: styles.css
    toc: true

Problems with write_yaml

library(yaml)
txt = c(
  "website:",
  "  title: 'reprex'",
  "  sidebar:",
  "    collapse-level: 1",
  "    style: docked",
  "    contents:",
  "      - text: Home",
  "        file: index.qmd",
  "      - section: Section Header",
  "        contents: ",
  "          - about.qmd"
)
yaml = yaml::yaml.load(txt)
file = tempfile()
write_yaml(yaml, file)
cat(readLines(file), sep = "\n")
#> website:
#>   title: reprex
#>   sidebar:
#>     collapse-level: 1
#>     style: docked
#>     contents:
#>     - text: Home
#>       file: index.qmd
#>     - section: Section Header
#>       contents: about.qmd

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.