For Reveal.js and Quarto
const http = require("http");
http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
}).listen(8081);
A ‘Copy’ button is automatically added to any pre
code block.
Quarto already has copy-code buttons, but those are quite small, and thus not very visible for presentations.
This extension replaces those buttons for use in Reveal.js Quarto presentations.
There are really only three steps:
The following command installs the plugin for use with Quarto:
Now refer to the plugin in the YAML:
You can change the visibility, icon use or texts easily per element:
Turn it off
Or show only on hover over the code block
This can also be set globally. See Global options.
Note: Hover-only codeblocks will always show the copy button on touch devices.
This can also be set globally.See Global options.
This can also be set globally. See Global options.
The options below have user configurable options. In a regular Reveal.js presentation, these can be set through JavaScript, but Quarto makes it configurable through YAML options.
The button
option is to show the button, always or only on hover.
The display
option is to show text in the button, icons, or both.
The text
option is an object that contains the texts for the ‘copy’ and ‘copied’ state.
The plaintextonly
option can be set to false to allow copying of rich text and styles.
The timeout
option is the time in milliseconds for the “Copied!”-state to revert back to “Copy”.
The style
option is an object that contains settings for background colors, colors, sizing, spacing and border styles.
The timeout
option makes sure that the ‘copied’ text is shown in a tooltip, when an icon-only button display is used.
The iconsvg
option is an object with placeholders for SVG icons for the ‘copy’ and ‘copied’ state. If left empty, it will use the default icons.
The csspath
option can be used when the you want to use your own stylesheet, instead of the provided one.
Use this if you really want to change things that you can’t override from the Reveal.js config, like the padding and so on.