Skip to content

conditionally including another qmd file depending on output format #676

Answered by jjallaire
donboyd5 asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by donboyd5
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants