klippy::klippy('')
The klippy
package enhances R Markdown
HTML
documents with copy to
clipboard buttons. You only have to paste the following chunk anywhere in
your Rmd
file.
Obviously, you have to try the clipboard button in the upper left corner of this chunk!
{#ex .markdown .klippy}
`r ''
r
klippy::klippy()
```` The `klippy()` function inserts a klippy[^1] in each `R` or `markdown` code block. ## Code block selection You can select which of the code blocks get a klippy. First, insert this chunk anywhere in your `Rmd` file: ````{#code-block-ex .markdown .klippy} `r ''````r klippy::klippy('')
Then, add the `klippy` class to a code chunk: ````{.markdown} `r ''````r summary(cars) ```
If you use other languages than R
in your Rmd
file, you can also add klippies
to these code blocks.
For example, if you want to add klippies to R
and python
code blocks, add this
chunk anywhere in your Rmd
file:
{.markdown .klippy}
`r ''
r
klippy::klippy(c('r', 'python'))
```` ## Icon positioning By default, `klippy` is positionned at the upper-left corner of the code chunks. You can choose another corner with `position` argument: ````{.markdown .klippy} `r ''````r klippy::klippy(position = c('top', 'right'))
## Color customization `klippy` color is the same as the links in the document. However, you can pick another color: ````{.markdown .klippy} `r ''````r klippy::klippy(color = 'darkred') ```
Tooltip messages can also be adapted:
{.markdown .klippy}
`r ''
r
klippy::klippy(tooltip_message = 'Click to copy', tooltip_success = 'Done')
```
````
For supported browsers, see clipboard.js
documentation.
[^1]: A klippy is a knitweaR clipboard button.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.