Disable anchors selectively for chunks #10274
Replies: 1 comment 3 replies
-
There is no way for now to opt out anchor on specific element. It is all of nothing through There is a trick though using internal logic we have (undocumented but can be a workaround for now for quarto 1.5) To be clear: No guarantee to keep this as it is in future versions Div = function(div)
-- get div that have a no-anchor class
if div.classes:includes('no-anchor') then
-- Remove this class we don't need in output
div.classes = div.classes:filter(function(class)
return class ~= 'no-anchor'
end)
return div:walk({
Div = function(div)
-- check all div inside and add no-anchor on figure with an id
if div.classes:includes('quarto-figure') and #div.identifier > 0 then
div.classes:insert('no-anchor')
end
return div
end
})
end
end
and add this to your YAML header filters:
- at: post-render
path: no-anchor.lua and adding in qmd ## ggiraph
```{r}
#| label: fig-ggiraph
#| fig-cap: A ggiraph figure
#| classes: no-anchor
library(ggiraph)
p1 <- p+labs(title="A ggiraph figure")
girafe(ggobj = p1) |>
girafe_options(opts_toolbar(saveaspng = TRUE))
``` Probably in the future, we'll need to add a way for this Hope this helps. And thanks for the idea. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
A code chunk with a label creates a clickable anchor. This is usually fine and nice to have.
But sometimes, with interactive graphics, it can conflict with existing elements.
anchor-sections: false
disables anchors for the whole document. Is it possible to disable anchors selectively by chunk? Or enable anchors for headings, but disable for figures?An example document
Click here
quarto 1.5.54
Beta Was this translation helpful? Give feedback.
All reactions