quarto-dev / quarto-cli

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

Defining format in `metadata-file` does not work to overwrite global config #6932

Open cderv opened 10 months ago

cderv commented 10 months ago

I have a set of presentations sharing its own _metadata.yml (and styles/backgrounds/...). I would like to have a Quarto website showing the list of those presentations, with the ability to watch the slides.

The problem: despite_metadata.yml defined and mentioned in .qmd metadata section, all slides generated with the styles of the website, not with their predefined styles.

The mve project to test

The question: is it ever possible to have separated styles of the quarto website AND styles of presentations to be shown at the site?

Originally posted by @nataschake in https://github.com/quarto-dev/quarto-cli/discussions/1033#discussioncomment-7068237

cderv commented 10 months ago

From https://quarto.org/docs/projects/quarto-projects.html#shared-metadata it seems that metadata can be shared several ways. metadata-files is also among what is explained: https://quarto.org/docs/projects/quarto-projects.html#metadata-includes

However, in project context, when resolving format, it seems the content is not taken into account to defined which format to render.

With format: html in _quarto.yml and format: revealjs in metadata-files: ['_revealjs-meta.yml'], quarto render will use html and not revealjs

See repo above for full example

Other minimal example

quarto create project default test-meta
cd test-meta

Then when doing quarto render, it will resolve to html and not revealjs.

> quarto render .\Test-meta.qmd
pandoc
  to: html
  output-file: Test-meta.html
  standalone: true
  section-divs: true
  html-math-method: mathjax
  wrap: none
  default-image-extension: png
  metadata-files:
    - _reveal-meta.yml

metadata
  document-css: false
  link-citations: true
  date-format: long
  lang: en
  title: Test-meta

Output created: Test-meta.html

Setting directly format: revealjs in test-meta.qmd will correctly render to document level format which revealjs

Should we merge metadata-files before resolving formats maybe ?

Not directly related but other issue with metadata-file behavior discussion: https://github.com/quarto-dev/quarto-cli/issues/6123

dragonstyle commented 10 months ago

I think the issue is how to distinguish that even though a page is linked from navigation and could be rendered to HTML, it should be rendered as revealjs. To me it makes sense that declaring format: revealjs is required in those documents (you can just add this to the files in the presentations folder and it will merge the shared revealjs configuration with them). I read this as declaring not merely that this page supports another additional format, but declaring that it should be definitively rendered as revealjs.

That seems ok / reasonable to me, what do you think?

cderv commented 10 months ago

To me it makes sense that declaring format: revealjs is required in those documents

I think I agree with that. format: revealjs is needed in the document.

However, this means you can add this format key using metadata includes with an external YAML file. It must be written in the document directly, and not provide through metadata-files

This is what I am wondering about. Our doc says a bout metadata-files

Files listed in metadata-files are merged with the parent file in the same fashion that project, directory, and document options are merged. This means that included files can both provide new options as well as combine with existing options.

One could understand that the file content will be merged with document level meta when use at document level.

To be clear, the behavior is fine to me. We should maybe just document better this format merging, especially not working with metadata-files