You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS: Pop!_OS 22.04 LTS x86_64 Quarto version: 0.9.550
Minimal example to reproduce error:
quarto create-project mybook --type book
Add conditional content to bottom of intro.qmd:
# Introduction
This is a book created from markdown and executable code.
See @knuth84 for additional discussion of literate programming.
::: {.content-visible when-format="html"}
Will only appear in HTML.
:::
Render book:
quarto render --to all
Encountered error:
Error running filter /opt/quarto/share/filters/quarto-pre/quarto-pre.lua:
/opt/quarto/share/filters/quarto-pre/quarto-pre.lua:217: attempt to call a nil value (field 'formatMatches')
stack traceback:
/opt/quarto/share/filters/quarto-pre/quarto-pre.lua:233: infunction'handleVisible'
(...tail calls...)
I just wanted to check if the following is expected behaviour:
The left side is the pdf output based on the following conditional content:
::: {.content-visible when-format="html"}
# A Chapter only for HTML
Will only appear in HTML.
## Introduction
This is a book created from markdown and executable code.
See @knuth84 for additional discussion of literate programming.
:::
The text is left out of the pdf format but the level 1 heading is still there.
@dragonstyle I think this is b/c we are taking the first header in partitiionMarkdown -- I wonder if need to be slightly more choosey and only take the header if its the first thing in the file?
I think there are some challenges to creating conditional chapters in this way (for example, if you were to try to create a PDF only chapter you'd end up with empty untitled pages in web or epub output). This sort of 'happens' to work for PDF chapters because of how we generate the book LaTeX, but it seems risky to rely upon.
Without proprocessing the _quarto.yml I don't know how to add a chapter to only one format, but pehaps @jjallaire has ideas here...
Regarding adding different set of chapters from different output format, bookdown configuration rmd_files, which is used to select the files to includes in the book, supports specifying a different set by format.
Reminder: the default in bookdown is to include all (R)md file found not prefixed by underscore. The rmd_files key is used to change this default behavior.
Just stumbled upon this very issue when trying to 'exclude' the index.md in non-HTML output. An index file is mandatory for books currently, but I do not need that output in the PDF.
::: {.content-visible when-format="html"}
# Preface {.unnumbered}
This is a webpage version of the PDF documentation for your convenience.
:::
Same issue arises for references, I use biblatex for PDF output and a custom bibliography.md (alongside an empty biblio.tex partial to remove the default behaviour)
@dragonstyle Let's take a look at this later on today to see if there isn't something simple we can do (I think we need a local repro that illustrates the problem so we can reason about it better). It seems like excluding content from PDFs should be much easier than excluding pages from the HTML website.
I think this is b/c we are taking the first header in partitiionMarkdown -- I wonder if need to be slightly more choosey and only take the header if its the first thing in the file?
Activity
dragonstyle commentedon Jun 8, 2022
Thanks for reporting this! Fixed here 57d6f2f and a fresh release is on the way.
bbartholdy commentedon Jun 9, 2022
Error has been resolved!
I just wanted to check if the following is expected behaviour:
The left side is the pdf output based on the following conditional content:
The text is left out of the pdf format but the level 1 heading is still there.
jjallaire commentedon Jun 9, 2022
@dragonstyle I think this is b/c we are taking the first header in
partitiionMarkdown-- I wonder if need to be slightly more choosey and only take the header if its the first thing in the file?dragonstyle commentedon Jun 9, 2022
I think there are some challenges to creating conditional chapters in this way (for example, if you were to try to create a PDF only chapter you'd end up with empty untitled pages in web or epub output). This sort of 'happens' to work for PDF chapters because of how we generate the book LaTeX, but it seems risky to rely upon.
Without proprocessing the
_quarto.ymlI don't know how to add a chapter to only one format, but pehaps @jjallaire has ideas here...cderv commentedon Jun 9, 2022
Regarding adding different set of chapters from different output format, bookdown configuration
rmd_files, which is used to select the files to includes in the book, supports specifying a different set by format.Reminder: the default in bookdown is to include all (R)md file found not prefixed by underscore. The
rmd_fileskey is used to change this default behavior.Search
rmd_filesin here for context: https://bookdown.org/yihui/bookdown/usage.htmlNot sure how complex it would be to support this type of configuration in our YAML. (unless it already exists ? I missed the doc in this case)
jjallaire commentedon Jun 11, 2022
Non we don't support that currently in YAML but we certainly could. I'm going to target this for post v1.0.
fitzchivalrik commentedon Jun 13, 2022
Just stumbled upon this very issue when trying to 'exclude' the
index.mdin non-HTML output. An index file is mandatory for books currently, but I do not need that output in the PDF.::: {.content-visible when-format="html"} # Preface {.unnumbered} This is a webpage version of the PDF documentation for your convenience. :::Same issue arises for references, I use
biblatexfor PDF output and a custombibliography.md(alongside an emptybiblio.texpartial to remove the default behaviour):::: {.content-visible when-format="html"} # Bibliography ::: {#refs} ::: :::: \printbibliography \clearpage \pagenumbering{Roman}This results in an additional empty 'Bibliography' chapter in PDF output, followed by the actual bibliography.
Just to give a few more examples where a complete 'content-removed when not condition' would be appreciated.
jjallaire commentedon Jun 13, 2022
@dragonstyle Let's take a look at this later on today to see if there isn't something simple we can do (I think we need a local repro that illustrates the problem so we can reason about it better). It seems like excluding content from PDFs should be much easier than excluding pages from the HTML website.
mpadge commentedon Jul 13, 2022
cderv commentedon Jul 13, 2022
salim-b commentedon Dec 15, 2022
@jjallaire Is #3681 also caused by this?
mcanouil commentedon Mar 29, 2025
Cannot reproduce on latest Quarto.