How to Directly Link a Plot Generated in a Code Chunk? #12351
-
DescriptionIs there a built-in way in Quarto to generate a plot within a code chunk and associate a hyperlink with it? For example, I’d like to wrap the plot in an tag that links to an external site: ---
title: Test
format: html
engine: knitr
---
<a href="https://cran.r-project.org/" target="_blank" rel="noopener">
```{r}
plot(1:10)
```
</a> However, this approach does not work as expected. Is there a recommended way to achieve this within Quarto without manually saving the plot and linking to the saved file? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
First, you should not use bare raw HTML (or any other languages) without telling Quarto what it is. Finally, about your question, you can leverage one of the two systems below:
For short, no there is not "Quarto CLI built-in" direct way. I suggest you look at |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response, @mcanouil. Please note that my example was never intended to work—it was solely meant to illustrate the feature. |
Beta Was this translation helpful? Give feedback.
First, you should not use bare raw HTML (or any other languages) without telling Quarto what it is.
See raw content.
Second, your example is invalid. YAML blocks use
---
(three) not----
(four) delimiters. Please be sure you've tried your example before sharing it.Finally, about your question, you can leverage one of the two systems below:
knitr
specific system such as hooks, print method, etc.For short, no there is not "Quarto CLI built-in" direct way.
I suggest you look at
keep-md: true
to understand what markdown is being emitted when trying out things. It helps understand why things do not work as expected.