From 7e718e574721ee6b788ba1649ade5d69df0930a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Matthias=20Sch=C3=A4fer?= Date: Mon, 25 Nov 2024 11:44:50 +0100 Subject: [PATCH] Add buttons to code block An accompanying patch for varnish adds a click listener to those buttons that puts the code blocks contents into the clipboard. --- R/utils-xml.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/utils-xml.R b/R/utils-xml.R index 3da96bf4..f9c21f24 100644 --- a/R/utils-xml.R +++ b/R/utils-xml.R @@ -99,6 +99,12 @@ add_code_heading <- function(codes = NULL, labels = "OUTPUT") { xml2::xml_add_child(head, "i", "aria-hidden" = "true", "data-feather" = "chevron-right") } + buttons <- xml2::xml_add_sibling(codes, "button", + class = "copy-button", .where = "before" + ) + for (button in buttons) { + xml2::xml_add_child(button, "i", "data-feather" = "copy") + } invisible(codes) }