-
I have a project in which I will have html and pdf formats. For the html format it is appropriate to have a section with a dynamic table that the reader can sort, etc. (generated in R with DT::datatable). In the pdf output it does not make sense to include this section and so I would like to exclude it. It seems like there are two ways in which quarto might have this capability, although I have not found either:
With that as background, is there a reasonably easy way in quarto to have sections included depending on output format, or to include them conditionally based on variables set at render time? If not, I think it would be a nice feature to add. Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
We are going to add these sorts of capabilities soon (including the ability to optionally embed a static screenshot of JavaScript backed widgets in PDFs Word, etc.). In the meantime, the best approach might be to mark your HTML-specific output with a class and then use a Lua filter to exclude it in non-HTML formats. You can see some format checks in our Lua filters here: https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/filters/common/pandoc.lua. The filter might look something like this (code not tested!) function Div(el)
if el.attr.classes:includes("html-only") and FORMAT == "pdf" then
return pandoc.Null()
end
end |
Beta Was this translation helpful? Give feedback.
-
For cross reference, related topic in #373 |
Beta Was this translation helpful? Give feedback.
We are going to add these sorts of capabilities soon (including the ability to optionally embed a static screenshot of JavaScript backed widgets in PDFs Word, etc.). In the meantime, the best approach might be to mark your HTML-specific output with a class and then use a Lua filter to exclude it in non-HTML formats. You can see some format checks in our Lua filters here: https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/filters/common/pandoc.lua. The filter might look something like this (code not tested!)