diff --git a/DESCRIPTION b/DESCRIPTION index a29ee95..69ae94b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,15 @@ Package: quartostamp Title: RStudio Addin to Insert Quarto Helpers -Version: 0.0.0.9001 +Version: 0.1.0 Authors@R: person("Matt", "Dray", , "mwdray@gmail.com", role = c("aut", "cre")) Description: An RStudio Addin to insert ('stamp') pre-written classes and divs into your Quarto documents. - URL: https://matt-dray.github.io/quartostamp/, https://github.com/matt-dray/quartostamp +URL: https://matt-dray.github.io/quartostamp/, https://github.com/matt-dray/quartostamp BugReports: https://github.com/matt-dray/quartostamp/issues License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 Imports: + clipr, rstudioapi diff --git a/NEWS.md b/NEWS.md index 267df8f..ffeb5ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# quartostamp 0.1.0 + +* Allowed functions to include the text selected by the user (where appropriate), rather than just inserting a simple skeleton (closes #6, thank you @Lextuga007). +* Added DRY utils functions to replace text and for common callout-box code. +* Updated function documentation to reflect changes. +* Bump version to v0.1.0. + # quartostamp 0.0.0.9001 * Added callout blocks with `stamp_callout_*()` (#1, suggested by @IndrajeetPatil). diff --git a/R/stamps.R b/R/stamps.R index 55a5966..f86c54d 100644 --- a/R/stamps.R +++ b/R/stamps.R @@ -1,10 +1,11 @@ - #' Insert Aside #' -#' Insert a div that creates an 'aside' in a Revealjs presentation slide. +#' Insert a div that creates an 'aside' in a Revealjs presentation slide. Will +#' embed text selected by the user, otherwise skeleton help text will be +#' inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' ::: aside #' Additional commentary. @@ -15,25 +16,25 @@ #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_aside <- function() { - rstudioapi::insertText( - paste0( - "::: aside\n", - "Additional commentary.\n", - ":::\n" - ) + .replace_text( + pre = "::: aside\n", + body = "Additional commentary.\n", + post = ":::\n" ) } - #' Insert 'Note' Callout Block #' #' Insert a callout-block div of type 'note', which has a blue accent and -#' a letter 'i' icon. +#' a letter 'i' icon. Will embed text selected bythe user, otherwise +#' skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' :::{.callout-note collapse=false appearance='default' icon=true} #' ## Optional caption (note) @@ -48,28 +49,21 @@ stamp_aside <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_callout_note <- function() { - rstudioapi::insertText( - paste0( - ":::{.callout-note collapse=false appearance='default' icon=true}\n", - "## Optional caption (note)\n", - "- Hide callout body with 'collapse=true'\n", - "- Remove 'collapse' to prevent expandability\n", - "- Set appearance to 'default', 'simple' or 'minimal'\n", - "- Remove icon with 'icon=false'\n", - ":::\n" - ) - ) + .insert_callout("note") } #' Insert 'Warning' Callout Block #' #' Insert a callout-block div of type 'warning', which has a yellow accent and -#' a warning-triangle icon. +#' a warning-triangle icon. Will embed text selected by the user, otherwise +#' skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' :::{.callout-warning collapse=false appearance='default' icon=true} #' ## Optional caption (warning) @@ -84,28 +78,21 @@ stamp_callout_note <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_callout_warning <- function() { - rstudioapi::insertText( - paste0( - ":::{.callout-warning collapse=false appearance='default' icon=true}\n", - "## Optional caption (warning)\n", - "- Hide callout body with 'collapse=true'\n", - "- Remove 'collapse' to prevent expandability\n", - "- Set appearance to 'default', 'simple' or 'minimal'\n", - "- Remove icon with 'icon=false'\n", - ":::\n" - ) - ) + .insert_callout("warning") } #' Insert 'Important' Callout Block #' #' Insert a callout-block div of type 'important', which has a red accent and -#' an exclamation-point icon. +#' an exclamation-point icon. Will embed text selected by the user, otherwise +#' skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' :::{.callout-important collapse=false appearance='default' icon=true} #' ## Optional caption (important) @@ -120,28 +107,21 @@ stamp_callout_warning <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_callout_important <- function() { - rstudioapi::insertText( - paste0( - ":::{.callout-important collapse=false appearance='default' icon=true}\n", - "## Optional caption (important)\n", - "- Hide callout body with 'collapse=true'\n", - "- Remove 'collapse' to prevent expandability\n", - "- Set appearance to 'default', 'simple' or 'minimal'\n", - "- Remove icon with 'icon=false'\n", - ":::\n" - ) - ) + .insert_callout("important") } #' Insert 'Tip' Callout Block #' #' Insert a callout-block div of type 'tip', which has an green accent and -#' a lightbulb icon. +#' a lightbulb icon. Will embed text selected by the user, otherwise skeleton +#' help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' :::{.callout-tip collapse=false appearance='default' icon=true} #' ## Optional caption (tip) @@ -156,28 +136,21 @@ stamp_callout_important <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_callout_tip <- function() { - rstudioapi::insertText( - paste0( - ":::{.callout-tip collapse=false appearance='default' icon=true}\n", - "## Optional caption (tip)\n", - "- Hide callout body with 'collapse=true'\n", - "- Remove 'collapse' to prevent expandability\n", - "- Set appearance to 'default', 'simple' or 'minimal'\n", - "- Remove icon with 'icon=false'\n", - ":::\n" - ) - ) + .insert_callout("tip") } #' Insert 'Caution' Callout Block #' #' Insert a callout-block div of type 'caution', which has an orange accent and -#' a traffic-cone icon. +#' a traffic-cone icon. Will embed text selected by the user, otherwise skeleton +#' help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' :::{.callout-caution collapse=false appearance='default' icon=true} #' ## Optional caption (caution) @@ -192,28 +165,22 @@ stamp_callout_tip <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_callout_caution <- function() { - rstudioapi::insertText( - paste0( - ":::{.callout-caution collapse=false appearance='default' icon=true}\n", - "## Optional caption (caution)\n", - "- Hide callout body with 'collapse=true'\n", - "- Remove 'collapse' to prevent expandability\n", - "- Set appearance to 'default', 'simple' or 'minimal'\n", - "- Remove icon with 'icon=false'\n", - ":::\n" - ) - ) + .insert_callout("caution") } #' Insert Column Layout #' #' Insert a div for a horizontal two-column layout with percentage widths in a -#' Revealjs presentation slide. +#' Revealjs presentation slide. Will embed text selected by the user into the +#' left column and helper text into the right, otherwise skeleton help text will +#' be inserted into both columns. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' :::: {.columns} #' @@ -232,14 +199,18 @@ stamp_callout_caution <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_columns <- function() { - rstudioapi::insertText( - paste0( + .replace_text( + pre = paste0( ":::: {.columns}\n", "\n", - "::: {.column width='40%'}\n", - "Left column\n", + "::: {.column width='40%'}\n" + ), + body = "Left column\n", + post = paste0( ":::\n", "\n", "::: {.column width='60%'}\n", @@ -257,7 +228,7 @@ stamp_columns <- function() { #' titles). #' #' @details -#' Output looks like this: +#' The output looks like this: #' ``` #' --- #' @@ -266,6 +237,8 @@ stamp_columns <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_divider <- function() { rstudioapi::insertText("---\n") @@ -273,10 +246,11 @@ stamp_divider <- function() { #' Insert Custom Footer #' -#' Insert a custom footer div in a Revealjs presentation slide. +#' Insert a custom footer div in a Revealjs presentation slide. Will include +#' text selected by the user, otherwise skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' ::: footer #' Custom footer text @@ -287,42 +261,96 @@ stamp_divider <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export -stamp_footer <- function() { - rstudioapi::insertText( - paste0( - "::: footer\n", - "Custom footer text\n", - ":::\n" - ) +stamp_footer <- function() { + .replace_text( + pre = "::: footer\n", + body = "Custom footer text\n", + post = ":::\n" ) } #' Insert Footnote #' -#' Insert a footnote marker. +#' Insert a footnote marker with skeleton text. If the user selects some text, +#' a modified version of it will be used to fill the footnote marker text +#' instead (spaces and punctuation will be removed and the string will be +#' trimmed to `trim_n`, which defaults to 10). +#' +#' @param trim_n Integer. The number of characters that the selected text should +#' be truncated to when used as the footnote marker text. +#' @param clip Logical. Should the footnote string be added to the clipboard so +#' the user can paste it at the bottom of the document? Defaiults to `TRUE`. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` -#' ^[A footnote] +#' Here is some text you wrote [^footnote]. #' ``` +#' And the console will state `Footnote '[^footnote]: Insert description.' added +#' to clipboard. Paste it at the bottom of your document.` #' #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document and footnote is added +#' to the clipboard. +#' #' @export -stamp_footnote <- function() { - rstudioapi::insertText("^[A footnote]") +stamp_footnote <- function(trim_n = 10L, clip = TRUE) { + + active_doc <- rstudioapi::getActiveDocumentContext() + + if (!is.null(active_doc)) { + + selected_text <- active_doc$selection[[1]]$text + has_selected_text <- nchar(selected_text) > 0 + selected_squashed <- + strtrim(gsub("[[:space:]]|[[:punct:]]", "", selected_text), trim_n) + + if (has_selected_text) { + inline_replace <- paste0(selected_text, " [^", selected_squashed, "]") + foot_insert <- paste0("[^", selected_squashed, "]: Insert description.") + } + + if (!has_selected_text) { + inline_replace <- paste0(selected_text, " [^footnote]") + foot_insert <- paste0("[^footnote]: Insert description.") + } + + rstudioapi::modifyRange(active_doc$selection[[1]]$range, inline_replace) + + if (clip) { + clipr::write_clip(foot_insert) + message( + paste0( + "The footnote '", foot_insert, + "' was added to the clipboard. Paste it at the bottom of your document." + ) + ) + } + + # You can't insert into a new row at the bottom of the document without + # first adding a row and saving over the user's document, which doesn't + # seem like a good idea. For now, use clipr::write_clip() instead.. + # foot_location <- + # rstudioapi::document_position(length(active_doc$contents) + 1, 1) + # rstudioapi::modifyRange(foot_location, text_replace) + + } + } #' Insert Incremental List #' #' Insert a list-containing div in a Revealjs presentation slide that is -#' revealed incrementally. +#' revealed incrementally. Will embed text selected by the user, otherwise +#' skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' ::: {.incremental} #' - List element A @@ -334,25 +362,28 @@ stamp_footnote <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_incremental <- function() { - rstudioapi::insertText( - paste0( - "::: {.incremental}\n", + .replace_text( + pre = "::: {.incremental}\n", + body = paste0( "- List element A\n", - "- List element B\n", - ":::\n" - ) + "- List element B\n" + ), + post = ":::\n" ) } #' Insert Non-Incremental List #' #' Insert a list-containing div to a Revealjs presentation slide that is not -#' revealed incrementally (overrides a global incremental reveal). +#' revealed incrementally (overrides a global incremental reveal). Will embed +#' text selected by the user, otherwise skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' ::: {.nonincremental} #' - List element A @@ -364,15 +395,17 @@ stamp_incremental <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_nonincremental <- function() { - rstudioapi::insertText( - paste0( - "::: {.nonincremental}\n", + .replace_text( + pre = "::: {.nonincremental}\n", + body = paste0( "- List element A\n", - "- List element B\n", - ":::" - ) + "- List element B\n" + ), + post = ":::\n" ) } @@ -381,7 +414,7 @@ stamp_nonincremental <- function() { #' Insert a pause marker into a Revealjs presentation slide. #' #' @details -#' Output looks like this: +#' The output looks like this: #' ``` #' . . . #' @@ -390,6 +423,8 @@ stamp_nonincremental <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_pause <- function() { rstudioapi::insertText(". . .\n") @@ -397,10 +432,11 @@ stamp_pause <- function() { #' Insert Speaker Notes #' -#' Insert a speaker notes div in a Revealjs presentation slide. +#' Insert a speaker notes div in a Revealjs presentation slide. Will embed +#' text selected by the user, otherwise skeleton help text will be inserted. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' ::: {.notes} #' Speaker notes (press 's' when presenting to switch to speaker mode). @@ -411,14 +447,14 @@ stamp_pause <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_notes <- function() { - rstudioapi::insertText( - paste0( - "::: {.notes}\n", - "Speaker notes (press 's' when presenting to switch to speaker mode).\n", - ":::\n" - ) + .replace_text( + pre = "::: {.notes}\n", + body = "Speaker notes (press 's' when presenting to switch to speaker mode).\n", + post = ":::\n" ) } @@ -436,6 +472,8 @@ stamp_notes <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_smaller <- function() { rstudioapi::insertText("{.smaller}") @@ -455,6 +493,8 @@ stamp_smaller <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_scrollable <- function() { rstudioapi::insertText("{.scrollable}") @@ -462,10 +502,12 @@ stamp_scrollable <- function() { #' Insert Tabset #' -#' Insert a panel tabset div to a Revealjs presentation slide. +#' Insert a panel tabset div to a Revealjs presentation slide. Will embed text +#' selected by the user into the first tab and skeleton help text into the +#' second, otherwise skeleton help text will be inserted into both tabs. #' #' @details -#' Output looks like this: +#' The output looks like this if the user hadn't selected any text: #' ``` #' ::: {.panel-tabset} #' @@ -484,15 +526,19 @@ stamp_scrollable <- function() { #' @references #' [The Quarto documentation website.](https://quarto.org/docs/reference/) #' +#' @return Nothing. Text is updated in the active document. +#' #' @export stamp_tabset <- function() { - rstudioapi::insertText( - paste0( + .replace_text( + pre = paste0( "::: {.panel-tabset}\n", "\n", "### Tab A\n", - "\n", - "Content for Tab A\n", + "\n" + ), + body = "Content for Tab A\n", + post = paste0( "\n", "### Tab B\n", "\n", diff --git a/R/utils.R b/R/utils.R new file mode 100644 index 0000000..8d1d0d8 --- /dev/null +++ b/R/utils.R @@ -0,0 +1,40 @@ +.replace_text <- function(pre, body, post) { + + active_doc <- rstudioapi::getActiveDocumentContext() + + if (!is.null(active_doc)) { + + selected_text <- active_doc$selection[[1]]$text + has_selected_text <- nchar(selected_text) > 0 + + if (has_selected_text) { + text_replace <- paste0(pre, paste0(selected_text, "\n"), post) + } + + if (!has_selected_text) { + text_replace <- paste0(pre, body, post) + } + + rstudioapi::modifyRange(active_doc$selection[[1]]$range, text_replace) + + } + +} + +.insert_callout <- function(type) { + + .replace_text( + pre = paste0( + ":::{.callout-", type, "collapse=false appearance='default' icon=true}\n", + "## Optional caption (", type, ")\n" + ), + body = paste0( + "- Hide callout body with 'collapse=true'\n", + "- Remove 'collapse' to prevent expandability\n", + "- Set appearance to 'default', 'simple' or 'minimal'\n", + "- Remove icon with 'icon=false'\n" + ), + post = ":::\n" + ) + +} diff --git a/README.md b/README.md index 5680f1b..d42e521 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ remotes::install_github("matt-dray/quartostamp") To use: -1. Put the cursor in your Quarto file where you'd like to insert an element -2. Click the 'RStudio Addins' dropdown at the top of the RStudio IDE -3. Scroll/search for 'QUARTOSTAMP' and click the function you want +1. Put the cursor in your Quarto file where you'd like to insert an element. Alternatively, highlight some text that you would like to use in the body of an element. +2. Click the 'RStudio Addins' dropdown at the top of the RStudio IDE. +3. Scroll/search for 'QUARTOSTAMP' and click the function you want. Use the help files to learn more about each function. They all start with `stamp_` so you can search like `?stamp_notes`. diff --git a/man/quartostamp-package.Rd b/man/quartostamp-package.Rd index 7eb8bc2..3e73b0b 100644 --- a/man/quartostamp-package.Rd +++ b/man/quartostamp-package.Rd @@ -8,11 +8,13 @@ \description{ \if{html}{\figure{logo.png}{options: align='right' alt='logo' width='120'}} -An RStudio Addin to insert ('stamp') pre-written classes and divs into your Quarto documents. URL: https://matt-dray.github.io/quartostamp/, https://github.com/matt-dray/quartostamp +An RStudio Addin to insert ('stamp') pre-written classes and divs into your Quarto documents. } \seealso{ Useful links: \itemize{ + \item \url{https://matt-dray.github.io/quartostamp/} + \item \url{https://github.com/matt-dray/quartostamp} \item Report bugs at \url{https://github.com/matt-dray/quartostamp/issues} } diff --git a/man/stamp_aside.Rd b/man/stamp_aside.Rd index 7565afe..a11ea35 100644 --- a/man/stamp_aside.Rd +++ b/man/stamp_aside.Rd @@ -6,11 +6,16 @@ \usage{ stamp_aside() } +\value{ +Nothing. Text is updated in the active document. +} \description{ -Insert a div that creates an 'aside' in a Revealjs presentation slide. +Insert a div that creates an 'aside' in a Revealjs presentation slide. Will +embed text selected by the user, otherwise skeleton help text will be +inserted. } \details{ -Output looks like this:\preformatted{::: aside +The output looks like this if the user hadn't selected any text:\preformatted{::: aside Additional commentary. ::: diff --git a/man/stamp_callout_caution.Rd b/man/stamp_callout_caution.Rd index 0519fa6..300e61c 100644 --- a/man/stamp_callout_caution.Rd +++ b/man/stamp_callout_caution.Rd @@ -6,12 +6,16 @@ \usage{ stamp_callout_caution() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a callout-block div of type 'caution', which has an orange accent and -a traffic-cone icon. +a traffic-cone icon. Will embed text selected by the user, otherwise skeleton +help text will be inserted. } \details{ -Output looks like this:\preformatted{:::\{.callout-caution collapse=false appearance='default' icon=true\} +The output looks like this if the user hadn't selected any text:\preformatted{:::\{.callout-caution collapse=false appearance='default' icon=true\} ## Optional caption (caution) - Hide callout body with 'collapse=true' - Remove 'collapse' to prevent expandability diff --git a/man/stamp_callout_important.Rd b/man/stamp_callout_important.Rd index b622bca..70f2760 100644 --- a/man/stamp_callout_important.Rd +++ b/man/stamp_callout_important.Rd @@ -6,12 +6,16 @@ \usage{ stamp_callout_important() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a callout-block div of type 'important', which has a red accent and -an exclamation-point icon. +an exclamation-point icon. Will embed text selected by the user, otherwise +skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{:::\{.callout-important collapse=false appearance='default' icon=true\} +The output looks like this if the user hadn't selected any text:\preformatted{:::\{.callout-important collapse=false appearance='default' icon=true\} ## Optional caption (important) - Hide callout body with 'collapse=true' - Remove 'collapse' to prevent expandability diff --git a/man/stamp_callout_note.Rd b/man/stamp_callout_note.Rd index de7a8b5..bd45894 100644 --- a/man/stamp_callout_note.Rd +++ b/man/stamp_callout_note.Rd @@ -6,12 +6,16 @@ \usage{ stamp_callout_note() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a callout-block div of type 'note', which has a blue accent and -a letter 'i' icon. +a letter 'i' icon. Will embed text selected bythe user, otherwise +skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{:::\{.callout-note collapse=false appearance='default' icon=true\} +The output looks like this if the user hadn't selected any text:\preformatted{:::\{.callout-note collapse=false appearance='default' icon=true\} ## Optional caption (note) - Hide callout body with 'collapse=true' - Remove 'collapse' to prevent expandability diff --git a/man/stamp_callout_tip.Rd b/man/stamp_callout_tip.Rd index beb678a..79874fc 100644 --- a/man/stamp_callout_tip.Rd +++ b/man/stamp_callout_tip.Rd @@ -6,12 +6,16 @@ \usage{ stamp_callout_tip() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a callout-block div of type 'tip', which has an green accent and -a lightbulb icon. +a lightbulb icon. Will embed text selected by the user, otherwise skeleton +help text will be inserted. } \details{ -Output looks like this:\preformatted{:::\{.callout-tip collapse=false appearance='default' icon=true\} +The output looks like this if the user hadn't selected any text:\preformatted{:::\{.callout-tip collapse=false appearance='default' icon=true\} ## Optional caption (tip) - Hide callout body with 'collapse=true' - Remove 'collapse' to prevent expandability diff --git a/man/stamp_callout_warning.Rd b/man/stamp_callout_warning.Rd index 79717a1..e46f69e 100644 --- a/man/stamp_callout_warning.Rd +++ b/man/stamp_callout_warning.Rd @@ -6,12 +6,16 @@ \usage{ stamp_callout_warning() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a callout-block div of type 'warning', which has a yellow accent and -a warning-triangle icon. +a warning-triangle icon. Will embed text selected by the user, otherwise +skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{:::\{.callout-warning collapse=false appearance='default' icon=true\} +The output looks like this if the user hadn't selected any text:\preformatted{:::\{.callout-warning collapse=false appearance='default' icon=true\} ## Optional caption (warning) - Hide callout body with 'collapse=true' - Remove 'collapse' to prevent expandability diff --git a/man/stamp_columns.Rd b/man/stamp_columns.Rd index 06529a7..92044c1 100644 --- a/man/stamp_columns.Rd +++ b/man/stamp_columns.Rd @@ -6,12 +6,17 @@ \usage{ stamp_columns() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a div for a horizontal two-column layout with percentage widths in a -Revealjs presentation slide. +Revealjs presentation slide. Will embed text selected by the user into the +left column and helper text into the right, otherwise skeleton help text will +be inserted into both columns. } \details{ -Output looks like this:\preformatted{:::: \{.columns\} +The output looks like this if the user hadn't selected any text:\preformatted{:::: \{.columns\} ::: \{.column width='40\%'\} Left column diff --git a/man/stamp_divider.Rd b/man/stamp_divider.Rd index ae75883..2cd6f68 100644 --- a/man/stamp_divider.Rd +++ b/man/stamp_divider.Rd @@ -6,12 +6,15 @@ \usage{ stamp_divider() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a slide divider in a Revealjs presentation (for slides without titles). } \details{ -Output looks like this:\preformatted{--- +The output looks like this:\preformatted{--- } } diff --git a/man/stamp_footer.Rd b/man/stamp_footer.Rd index 0e3933b..d1d1a03 100644 --- a/man/stamp_footer.Rd +++ b/man/stamp_footer.Rd @@ -6,11 +6,15 @@ \usage{ stamp_footer() } +\value{ +Nothing. Text is updated in the active document. +} \description{ -Insert a custom footer div in a Revealjs presentation slide. +Insert a custom footer div in a Revealjs presentation slide. Will include +text selected by the user, otherwise skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{::: footer +The output looks like this if the user hadn't selected any text:\preformatted{::: footer Custom footer text ::: diff --git a/man/stamp_footnote.Rd b/man/stamp_footnote.Rd index 01eea42..4c506b4 100644 --- a/man/stamp_footnote.Rd +++ b/man/stamp_footnote.Rd @@ -4,14 +4,30 @@ \alias{stamp_footnote} \title{Insert Footnote} \usage{ -stamp_footnote() +stamp_footnote(trim_n = 10L, clip = TRUE) +} +\arguments{ +\item{trim_n}{Integer. The number of characters that the selected text should +be truncated to when used as the footnote marker text.} + +\item{clip}{Logical. Should the footnote string be added to the clipboard so +the user can paste it at the bottom of the document? Defaiults to \code{TRUE}.} +} +\value{ +Nothing. Text is updated in the active document and footnote is added +to the clipboard. } \description{ -Insert a footnote marker. +Insert a footnote marker with skeleton text. If the user selects some text, +a modified version of it will be used to fill the footnote marker text +instead (spaces and punctuation will be removed and the string will be +trimmed to \code{trim_n}, which defaults to 10). } \details{ -Output looks like this:\preformatted{^[A footnote] +The output looks like this if the user hadn't selected any text:\preformatted{Here is some text you wrote [^footnote]. } + +And the console will state \verb{Footnote '[^footnote]: Insert description.' added to clipboard. Paste it at the bottom of your document.} } \references{ \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} diff --git a/man/stamp_incremental.Rd b/man/stamp_incremental.Rd index 22d1f84..06c815a 100644 --- a/man/stamp_incremental.Rd +++ b/man/stamp_incremental.Rd @@ -6,12 +6,16 @@ \usage{ stamp_incremental() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a list-containing div in a Revealjs presentation slide that is -revealed incrementally. +revealed incrementally. Will embed text selected by the user, otherwise +skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{::: \{.incremental\} +The output looks like this if the user hadn't selected any text:\preformatted{::: \{.incremental\} - List element A - List element B ::: diff --git a/man/stamp_nonincremental.Rd b/man/stamp_nonincremental.Rd index 137dc96..91acaf8 100644 --- a/man/stamp_nonincremental.Rd +++ b/man/stamp_nonincremental.Rd @@ -6,12 +6,16 @@ \usage{ stamp_nonincremental() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a list-containing div to a Revealjs presentation slide that is not -revealed incrementally (overrides a global incremental reveal). +revealed incrementally (overrides a global incremental reveal). Will embed +text selected by the user, otherwise skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{::: \{.nonincremental\} +The output looks like this if the user hadn't selected any text:\preformatted{::: \{.nonincremental\} - List element A - List element B ::: diff --git a/man/stamp_notes.Rd b/man/stamp_notes.Rd index dddd0e7..cb4cc3d 100644 --- a/man/stamp_notes.Rd +++ b/man/stamp_notes.Rd @@ -6,11 +6,15 @@ \usage{ stamp_notes() } +\value{ +Nothing. Text is updated in the active document. +} \description{ -Insert a speaker notes div in a Revealjs presentation slide. +Insert a speaker notes div in a Revealjs presentation slide. Will embed +text selected by the user, otherwise skeleton help text will be inserted. } \details{ -Output looks like this:\preformatted{::: \{.notes\} +The output looks like this if the user hadn't selected any text:\preformatted{::: \{.notes\} Speaker notes (press 's' when presenting to switch to speaker mode). ::: diff --git a/man/stamp_pause.Rd b/man/stamp_pause.Rd index d379c7c..0da8326 100644 --- a/man/stamp_pause.Rd +++ b/man/stamp_pause.Rd @@ -6,11 +6,14 @@ \usage{ stamp_pause() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a pause marker into a Revealjs presentation slide. } \details{ -Output looks like this:\preformatted{. . . +The output looks like this:\preformatted{. . . } } diff --git a/man/stamp_scrollable.Rd b/man/stamp_scrollable.Rd index f916344..68a1bed 100644 --- a/man/stamp_scrollable.Rd +++ b/man/stamp_scrollable.Rd @@ -6,6 +6,9 @@ \usage{ stamp_scrollable() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a class that allows content to be scrolled if the slide is too small to hold it (place on the same line as the slide title). diff --git a/man/stamp_smaller.Rd b/man/stamp_smaller.Rd index 8d0d4a3..2968758 100644 --- a/man/stamp_smaller.Rd +++ b/man/stamp_smaller.Rd @@ -6,6 +6,9 @@ \usage{ stamp_smaller() } +\value{ +Nothing. Text is updated in the active document. +} \description{ Insert a class that makes the font smaller in a Revealjs presentation slide (place on the same line as the slide title). diff --git a/man/stamp_tabset.Rd b/man/stamp_tabset.Rd index eeed31b..d7a8350 100644 --- a/man/stamp_tabset.Rd +++ b/man/stamp_tabset.Rd @@ -6,11 +6,16 @@ \usage{ stamp_tabset() } +\value{ +Nothing. Text is updated in the active document. +} \description{ -Insert a panel tabset div to a Revealjs presentation slide. +Insert a panel tabset div to a Revealjs presentation slide. Will embed text +selected by the user into the first tab and skeleton help text into the +second, otherwise skeleton help text will be inserted into both tabs. } \details{ -Output looks like this:\preformatted{::: \{.panel-tabset\} +The output looks like this if the user hadn't selected any text:\preformatted{::: \{.panel-tabset\} ### Tab A