How to disable default behavior of callouts for unsupported formats? #13502
-
DescriptionDear quarto community, I would like to make code solutions available to students as a collapsible callout. This works great in HTML, but students should also be able to download the solutions as Jupyter notebooks to run the code (without callouts). Please find a minimal working example below. Unfortunately, the default behavior of replacing callouts with blockquotes in unsupported formats, breaks the Jupyter code cell. I have played with conditional content based on the output format, but I cannot put the opening and closing fences as conditional content. Any idea how to solve this? Thanks a lot! ---
title: Callouts for HTML, but not for notebooks
format:
html: default
ipynb: default
engine: jupyter
---
## First try (looks good in html, but breaks code cell in notebook)
Q: What is 1 + 1?
::: {.callout-tip collapse="true"}
# Solution
```{python}
print(1 + 1)
```
:::
## Second try (does not work)
Q: What is 1 + 1?
:::: {.content-visible unless-format="ipynb"}
::: {.callout-tip collapse="true"}
# Solution
::::
```{python}
print(1 + 1)
```
:::: {.content-visible unless-format="ipynb"}
:::
:::: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Did you look at what others did?
(Not exhaustive list)
Not directly, but you could make a Lua filter. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reproducible example. This looks like something we would need to handle better indeed for Currently the same default for What would you expect to be kept exactly? Only the content and use the callout inside title as a regular title ? ![]() Jupyter notebook cells does not have nested structure - so that is what makes it hards I am interested in your thoughts about the output to think about an alternative for
For example to completely ignore the callout in Ipynb output you could do a lua filter as suggestion filters: ['ignore-callout.lua'] Callout = function(callout)
if quarto.doc.is_format("ipynb") then
return callout.content
end
return callout
end ![]() or if you want at least to keep the title Callout = function(callout)
if quarto.doc.is_format("ipynb") then
content = callout.content
title = pandoc.Strong(pandoc.utils.blocks_to_inlines({callout.title}))
return pandoc.Blocks({title, content})
end
return callout
end ![]() Hope it helps |
Beta Was this translation helpful? Give feedback.
-
Thanks @mcanouil for the list. I saw some of these, but did not find anything on the callout behavior in Thanks to the whole team for the amazing work on Quarto! |
Beta Was this translation helpful? Give feedback.
Thanks for the reproducible example. This looks like something we would need to handle better indeed for
--to ipynb
Currently the same default for
BlockQuote
is used for all outputs formats. We could maybe make an exception for ipynb.What would you expect to be kept exactly? Only the content and use the callout inside title as a regular title ?
Or would you expect the content…