├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ └── pkgdown.yaml ├── LICENSE ├── man ├── figures │ └── logo.png ├── stamp_pause.Rd ├── stamp_divider.Rd ├── stamp_smaller.Rd ├── stamp_scrollable.Rd ├── stamp_footer.Rd ├── stamp_aside.Rd ├── stamp_notes.Rd ├── stamp_incremental.Rd ├── stamp_nonincremental.Rd ├── stamp_tabset.Rd ├── quartostamp-package.Rd ├── stamp_columns.Rd ├── stamp_callout_tip.Rd ├── stamp_callout_note.Rd ├── stamp_callout_caution.Rd ├── stamp_callout_warning.Rd ├── stamp_callout_important.Rd └── stamp_footnote.Rd ├── .Rbuildignore ├── R ├── quartostamp-package.R ├── utils.R └── stamps.R ├── quartostamp.Rproj ├── NAMESPACE ├── DESCRIPTION ├── _pkgdown.yml ├── .gitignore ├── LICENSE.md ├── NEWS.md ├── README.md └── inst └── rstudio └── addins.dcf /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2022 2 | COPYRIGHT HOLDER: quartostamp authors 3 | -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt-dray/quartostamp/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^quartostamp\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^LICENSE\.md$ 4 | ^_pkgdown\.yml$ 5 | ^docs$ 6 | ^pkgdown$ 7 | ^\.github$ 8 | -------------------------------------------------------------------------------- /R/quartostamp-package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | "_PACKAGE" 3 | 4 | ## usethis namespace: start 5 | ## usethis namespace: end 6 | NULL 7 | -------------------------------------------------------------------------------- /quartostamp.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | LineEndingConversion: Posix 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(stamp_aside) 4 | export(stamp_callout_caution) 5 | export(stamp_callout_important) 6 | export(stamp_callout_note) 7 | export(stamp_callout_tip) 8 | export(stamp_callout_warning) 9 | export(stamp_columns) 10 | export(stamp_divider) 11 | export(stamp_footer) 12 | export(stamp_footnote) 13 | export(stamp_incremental) 14 | export(stamp_nonincremental) 15 | export(stamp_notes) 16 | export(stamp_pause) 17 | export(stamp_scrollable) 18 | export(stamp_smaller) 19 | export(stamp_tabset) 20 | -------------------------------------------------------------------------------- /man/stamp_pause.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_pause} 4 | \alias{stamp_pause} 5 | \title{Insert Pause} 6 | \usage{ 7 | stamp_pause() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a pause marker into a Revealjs presentation slide. 14 | } 15 | \details{ 16 | The output looks like this: 17 | 18 | \if{html}{\out{
}}\preformatted{. . . 19 | 20 | }\if{html}{\out{
}} 21 | } 22 | \references{ 23 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 24 | } 25 | -------------------------------------------------------------------------------- /man/stamp_divider.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_divider} 4 | \alias{stamp_divider} 5 | \title{Insert Slide Divider} 6 | \usage{ 7 | stamp_divider() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a slide divider in a Revealjs presentation (for slides without 14 | titles). 15 | } 16 | \details{ 17 | The output looks like this: 18 | 19 | \if{html}{\out{
}}\preformatted{--- 20 | 21 | }\if{html}{\out{
}} 22 | } 23 | \references{ 24 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 25 | } 26 | -------------------------------------------------------------------------------- /man/stamp_smaller.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_smaller} 4 | \alias{stamp_smaller} 5 | \title{Insert Smaller Font} 6 | \usage{ 7 | stamp_smaller() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a class that makes the font smaller in a Revealjs presentation slide 14 | (place on the same line as the slide title). 15 | } 16 | \details{ 17 | Output looks like this: 18 | 19 | \if{html}{\out{
}}\preformatted{\{.smaller\} 20 | }\if{html}{\out{
}} 21 | } 22 | \references{ 23 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 24 | } 25 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: quartostamp 2 | Title: RStudio Addin to Insert Quarto Helpers 3 | Version: 0.1.1 4 | Authors@R: c( 5 | person("Matt", "Dray", , "mwdray@gmail.com", role = c("aut", "cre")), 6 | person("Zoë", "Turner", role = "ctb", comment = c(ORCID = "0000-0003-1033-9158")) 7 | ) 8 | Description: An RStudio Addin to insert ('stamp') pre-written classes and divs 9 | into your Quarto documents. 10 | URL: https://matt-dray.github.io/quartostamp/, https://github.com/matt-dray/quartostamp 11 | BugReports: https://github.com/matt-dray/quartostamp/issues 12 | License: MIT + file LICENSE 13 | Encoding: UTF-8 14 | Roxygen: list(markdown = TRUE) 15 | RoxygenNote: 7.2.3 16 | Imports: 17 | cli, 18 | clipr, 19 | rstudioapi 20 | -------------------------------------------------------------------------------- /man/stamp_scrollable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_scrollable} 4 | \alias{stamp_scrollable} 5 | \title{Insert Scrollable Content} 6 | \usage{ 7 | stamp_scrollable() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a class that allows content to be scrolled if the slide is too small 14 | to hold it (place on the same line as the slide title). 15 | } 16 | \details{ 17 | Output looks like this: 18 | 19 | \if{html}{\out{
}}\preformatted{\{.scrollable\} 20 | }\if{html}{\out{
}} 21 | } 22 | \references{ 23 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 24 | } 25 | -------------------------------------------------------------------------------- /man/stamp_footer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_footer} 4 | \alias{stamp_footer} 5 | \title{Insert Custom Footer} 6 | \usage{ 7 | stamp_footer() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a custom footer div in a Revealjs presentation slide. Will include 14 | text selected by the user, otherwise skeleton help text will be inserted. 15 | } 16 | \details{ 17 | The output looks like this if the user hadn't selected any text: 18 | 19 | \if{html}{\out{
}}\preformatted{::: footer 20 | Custom footer text 21 | ::: 22 | 23 | }\if{html}{\out{
}} 24 | } 25 | \references{ 26 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 27 | } 28 | -------------------------------------------------------------------------------- /man/stamp_aside.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_aside} 4 | \alias{stamp_aside} 5 | \title{Insert Aside} 6 | \usage{ 7 | stamp_aside() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a div that creates an 'aside' in a Revealjs presentation slide. Will 14 | embed text selected by the user, otherwise skeleton help text will be 15 | inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{::: aside 21 | Additional commentary. 22 | ::: 23 | 24 | }\if{html}{\out{
}} 25 | } 26 | \references{ 27 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 28 | } 29 | -------------------------------------------------------------------------------- /man/stamp_notes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_notes} 4 | \alias{stamp_notes} 5 | \title{Insert Speaker Notes} 6 | \usage{ 7 | stamp_notes() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a speaker notes div in a Revealjs presentation slide. Will embed 14 | text selected by the user, otherwise skeleton help text will be inserted. 15 | } 16 | \details{ 17 | The output looks like this if the user hadn't selected any text: 18 | 19 | \if{html}{\out{
}}\preformatted{::: \{.notes\} 20 | Speaker notes (press 's' when presenting to switch to speaker mode). 21 | ::: 22 | 23 | }\if{html}{\out{
}} 24 | } 25 | \references{ 26 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 27 | } 28 | -------------------------------------------------------------------------------- /man/stamp_incremental.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_incremental} 4 | \alias{stamp_incremental} 5 | \title{Insert Incremental List} 6 | \usage{ 7 | stamp_incremental() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a list-containing div in a Revealjs presentation slide that is 14 | revealed incrementally. Will embed text selected by the user, otherwise 15 | skeleton help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{::: \{.incremental\} 21 | - List element A 22 | - List element B 23 | ::: 24 | 25 | }\if{html}{\out{
}} 26 | } 27 | \references{ 28 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 29 | } 30 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://github.com/matt-dray/quartostamp/ 2 | 3 | template: 4 | bootstrap: 5 5 | bslib: 6 | primary: "#729fd5" 7 | 8 | reference: 9 | - title: "Classes" 10 | desc: "Classes that impact the content of a Quarto slide if placed on the same row as the slide title. These are surrounded by curly braces (i.e. `{}`)." 11 | contents: 12 | - contains("smaller") 13 | - contains("scrollable") 14 | - title: "Divs" 15 | desc: "Div blocks that style the content you put inside them. These are fenced by multiple colons (e.g. `:::`)." 16 | contents: 17 | - contains("aside") 18 | - contains("callout") 19 | - contains("columns") 20 | - contains("footer") 21 | - contains("incremental") 22 | - contains("notes") 23 | - contains("tabset") 24 | - title: "Other" 25 | desc: "Other miscellaneous elements." 26 | contents: 27 | - contains("divider") 28 | - contains("footnote") 29 | - contains("pause") 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | .RDataTmp 8 | 9 | # User-specific files 10 | .Ruserdata 11 | 12 | # Example code in package build process 13 | *-Ex.R 14 | 15 | # Output files from R CMD build 16 | /*.tar.gz 17 | 18 | # Output files from R CMD check 19 | /*.Rcheck/ 20 | 21 | # RStudio files 22 | .Rproj.user/ 23 | 24 | # produced vignettes 25 | vignettes/*.html 26 | vignettes/*.pdf 27 | 28 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 29 | .httr-oauth 30 | 31 | # knitr and R markdown default cache directories 32 | *_cache/ 33 | /cache/ 34 | 35 | # Temporary files created by R markdown 36 | *.utf8.md 37 | *.knit.md 38 | 39 | # R Environment Variables 40 | .Renviron 41 | 42 | # pkgdown site 43 | docs/ 44 | 45 | # translation temp files 46 | po/*~ 47 | 48 | # RStudio Connect folder 49 | rsconnect/ 50 | 51 | # macOS 52 | .DS_Store 53 | docs 54 | -------------------------------------------------------------------------------- /man/stamp_nonincremental.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_nonincremental} 4 | \alias{stamp_nonincremental} 5 | \title{Insert Non-Incremental List} 6 | \usage{ 7 | stamp_nonincremental() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a list-containing div to a Revealjs presentation slide that is not 14 | revealed incrementally (overrides a global incremental reveal). Will embed 15 | text selected by the user, otherwise skeleton help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{::: \{.nonincremental\} 21 | - List element A 22 | - List element B 23 | ::: 24 | 25 | }\if{html}{\out{
}} 26 | } 27 | \references{ 28 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 29 | } 30 | -------------------------------------------------------------------------------- /man/stamp_tabset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_tabset} 4 | \alias{stamp_tabset} 5 | \title{Insert Tabset} 6 | \usage{ 7 | stamp_tabset() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a panel tabset div to a Revealjs presentation slide. Will embed text 14 | selected by the user into the first tab and skeleton help text into the 15 | second, otherwise skeleton help text will be inserted into both tabs. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{::: \{.panel-tabset\} 21 | 22 | ## Tab A 23 | 24 | Content for Tab A 25 | 26 | ## Tab B 27 | 28 | Content for Tab B 29 | 30 | ::: 31 | 32 | }\if{html}{\out{
}} 33 | } 34 | \references{ 35 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 36 | } 37 | -------------------------------------------------------------------------------- /man/quartostamp-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/quartostamp-package.R 3 | \docType{package} 4 | \name{quartostamp-package} 5 | \alias{quartostamp} 6 | \alias{quartostamp-package} 7 | \title{quartostamp: RStudio Addin to Insert Quarto Helpers} 8 | \description{ 9 | \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} 10 | 11 | An RStudio Addin to insert ('stamp') pre-written classes and divs into your Quarto documents. 12 | } 13 | \seealso{ 14 | Useful links: 15 | \itemize{ 16 | \item \url{https://matt-dray.github.io/quartostamp/} 17 | \item \url{https://github.com/matt-dray/quartostamp} 18 | \item Report bugs at \url{https://github.com/matt-dray/quartostamp/issues} 19 | } 20 | 21 | } 22 | \author{ 23 | \strong{Maintainer}: Matt Dray \email{mwdray@gmail.com} 24 | 25 | Other contributors: 26 | \itemize{ 27 | \item Zoë Turner (\href{https://orcid.org/0000-0003-1033-9158}{ORCID}) [contributor] 28 | } 29 | 30 | } 31 | \keyword{internal} 32 | -------------------------------------------------------------------------------- /man/stamp_columns.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_columns} 4 | \alias{stamp_columns} 5 | \title{Insert Column Layout} 6 | \usage{ 7 | stamp_columns() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a div for a horizontal two-column layout with percentage widths in a 14 | Revealjs presentation slide. Will embed text selected by the user into the 15 | left column and helper text into the right, otherwise skeleton help text will 16 | be inserted into both columns. 17 | } 18 | \details{ 19 | The output looks like this if the user hadn't selected any text: 20 | 21 | \if{html}{\out{
}}\preformatted{:::: \{.columns\} 22 | 23 | ::: \{.column width='40\%'\} 24 | Left column 25 | ::: 26 | 27 | ::: \{.column width='60\%'\} 28 | Right column 29 | ::: 30 | 31 | :::: 32 | 33 | }\if{html}{\out{
}} 34 | } 35 | \references{ 36 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 37 | } 38 | -------------------------------------------------------------------------------- /man/stamp_callout_tip.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_callout_tip} 4 | \alias{stamp_callout_tip} 5 | \title{Insert 'Tip' Callout Block} 6 | \usage{ 7 | stamp_callout_tip() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a callout-block div of type 'tip', which has an green accent and 14 | a lightbulb icon. Will embed text selected by the user, otherwise skeleton 15 | help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{:::\{.callout-tip collapse=false appearance='default' icon=true\} 21 | ## Optional caption (tip) 22 | - Hide callout body with 'collapse=true' 23 | - Remove 'collapse' to prevent expandability 24 | - Set appearance to 'default', 'simple' or 'minimal' 25 | - Remove icon with 'icon=false' 26 | ::: 27 | 28 | }\if{html}{\out{
}} 29 | } 30 | \references{ 31 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 32 | } 33 | -------------------------------------------------------------------------------- /man/stamp_callout_note.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_callout_note} 4 | \alias{stamp_callout_note} 5 | \title{Insert 'Note' Callout Block} 6 | \usage{ 7 | stamp_callout_note() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a callout-block div of type 'note', which has a blue accent and 14 | a letter 'i' icon. Will embed text selected bythe user, otherwise 15 | skeleton help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{:::\{.callout-note collapse=false appearance='default' icon=true\} 21 | ## Optional caption (note) 22 | - Hide callout body with 'collapse=true' 23 | - Remove 'collapse' to prevent expandability 24 | - Set appearance to 'default', 'simple' or 'minimal' 25 | - Remove icon with 'icon=false' 26 | ::: 27 | 28 | }\if{html}{\out{
}} 29 | } 30 | \references{ 31 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 32 | } 33 | -------------------------------------------------------------------------------- /man/stamp_callout_caution.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_callout_caution} 4 | \alias{stamp_callout_caution} 5 | \title{Insert 'Caution' Callout Block} 6 | \usage{ 7 | stamp_callout_caution() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a callout-block div of type 'caution', which has an orange accent and 14 | a traffic-cone icon. Will embed text selected by the user, otherwise skeleton 15 | help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{:::\{.callout-caution collapse=false appearance='default' icon=true\} 21 | ## Optional caption (caution) 22 | - Hide callout body with 'collapse=true' 23 | - Remove 'collapse' to prevent expandability 24 | - Set appearance to 'default', 'simple' or 'minimal' 25 | - Remove icon with 'icon=false' 26 | ::: 27 | 28 | }\if{html}{\out{
}} 29 | } 30 | \references{ 31 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2022 quartostamp authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /man/stamp_callout_warning.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_callout_warning} 4 | \alias{stamp_callout_warning} 5 | \title{Insert 'Warning' Callout Block} 6 | \usage{ 7 | stamp_callout_warning() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a callout-block div of type 'warning', which has a yellow accent and 14 | a warning-triangle icon. Will embed text selected by the user, otherwise 15 | skeleton help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{:::\{.callout-warning collapse=false appearance='default' icon=true\} 21 | ## Optional caption (warning) 22 | - Hide callout body with 'collapse=true' 23 | - Remove 'collapse' to prevent expandability 24 | - Set appearance to 'default', 'simple' or 'minimal' 25 | - Remove icon with 'icon=false' 26 | ::: 27 | 28 | }\if{html}{\out{
}} 29 | } 30 | \references{ 31 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 32 | } 33 | -------------------------------------------------------------------------------- /man/stamp_callout_important.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_callout_important} 4 | \alias{stamp_callout_important} 5 | \title{Insert 'Important' Callout Block} 6 | \usage{ 7 | stamp_callout_important() 8 | } 9 | \value{ 10 | Nothing. Text is updated in the active document. 11 | } 12 | \description{ 13 | Insert a callout-block div of type 'important', which has a red accent and 14 | an exclamation-point icon. Will embed text selected by the user, otherwise 15 | skeleton help text will be inserted. 16 | } 17 | \details{ 18 | The output looks like this if the user hadn't selected any text: 19 | 20 | \if{html}{\out{
}}\preformatted{:::\{.callout-important collapse=false appearance='default' icon=true\} 21 | ## Optional caption (important) 22 | - Hide callout body with 'collapse=true' 23 | - Remove 'collapse' to prevent expandability 24 | - Set appearance to 'default', 'simple' or 'minimal' 25 | - Remove icon with 'icon=false' 26 | ::: 27 | 28 | }\if{html}{\out{
}} 29 | } 30 | \references{ 31 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 32 | } 33 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | .replace_text <- function(pre, body, post) { 2 | 3 | active_doc <- rstudioapi::getActiveDocumentContext() 4 | 5 | if (!is.null(active_doc)) { 6 | 7 | selected_text <- active_doc$selection[[1]]$text 8 | has_selected_text <- nchar(selected_text) > 0 9 | 10 | if (has_selected_text) { 11 | text_replace <- paste0(pre, paste0(selected_text, "\n"), post) 12 | } 13 | 14 | if (!has_selected_text) { 15 | text_replace <- paste0(pre, body, post) 16 | } 17 | 18 | rstudioapi::modifyRange(active_doc$selection[[1]]$range, text_replace) 19 | 20 | } 21 | 22 | } 23 | 24 | .insert_callout <- function(type) { 25 | 26 | .replace_text( 27 | pre = paste0( 28 | ":::{.callout-", type, " collapse=false appearance='default' icon=true}\n", 29 | "## Optional caption (", type, ")\n" 30 | ), 31 | body = paste0( 32 | "- Hide callout body with 'collapse=true'\n", 33 | "- Remove 'collapse' to prevent expandability\n", 34 | "- Set appearance to 'default', 'simple' or 'minimal'\n", 35 | "- Remove icon with 'icon=false'\n" 36 | ), 37 | post = ":::\n" 38 | ) 39 | 40 | } 41 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # quartostamp 0.1.1 2 | 3 | * Replaced level 3 wih level 2 headers in tabsets (PR #12 closes #10, thank you @Lextuga007). 4 | * Added Zoë Turner (@Lextuga007) as contributor. 5 | 6 | # quartostamp 0.1.0 7 | 8 | * Allowed functions to include the text selected by the user (where appropriate), rather than just inserting a simple skeleton (closes #6, thank you @Lextuga007). 9 | * Added DRY utils functions to replace text and for common callout-box code. 10 | * Added messaging for users so they know that the footnote has been added to their clipboard. 11 | * Updated function documentation to reflect changes. 12 | * Added {clipr} and {cli}. 13 | * Bump version to v0.1.0. 14 | 15 | # quartostamp 0.0.0.9001 16 | 17 | * Added callout blocks with `stamp_callout_*()` (#1, suggested by @IndrajeetPatil). 18 | * Added sections to the reference page on the package website. 19 | * Updated some wording in the documentation throughout. 20 | * Added 'details' and 'references' in the function documentation. 21 | 22 | # quartostamp 0.0.0.9000 23 | 24 | * Set up package with license, news, readme. 25 | * Added RStudio Addins infrastructure (inst/rstudio/addins.dcf). 26 | * Added first `stamp_()` functions. 27 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macOS-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - uses: r-lib/actions/setup-pandoc@v1 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: rcmdcheck 45 | 46 | - uses: r-lib/actions/check-r-package@v2 47 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | name: pkgdown 13 | 14 | jobs: 15 | pkgdown: 16 | runs-on: ubuntu-latest 17 | # Only restrict concurrency for non-PR jobs 18 | concurrency: 19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 20 | env: 21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 22 | permissions: 23 | contents: write 24 | steps: 25 | - uses: actions/checkout@v3 26 | 27 | - uses: r-lib/actions/setup-pandoc@v2 28 | 29 | - uses: r-lib/actions/setup-r@v2 30 | with: 31 | use-public-rspm: true 32 | 33 | - uses: r-lib/actions/setup-r-dependencies@v2 34 | with: 35 | extra-packages: any::pkgdown, local::. 36 | needs: website 37 | 38 | - name: Build site 39 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 40 | shell: Rscript {0} 41 | 42 | - name: Deploy to GitHub pages 🚀 43 | if: github.event_name != 'pull_request' 44 | uses: JamesIves/github-pages-deploy-action@v4.4.1 45 | with: 46 | clean: false 47 | branch: gh-pages 48 | folder: docs 49 | -------------------------------------------------------------------------------- /man/stamp_footnote.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stamps.R 3 | \name{stamp_footnote} 4 | \alias{stamp_footnote} 5 | \title{Insert Footnote} 6 | \usage{ 7 | stamp_footnote(clip = TRUE) 8 | } 9 | \arguments{ 10 | \item{clip}{Logical. Should the footnote string be added to the clipboard so 11 | the user can paste it at the bottom of the document? Defaults to \code{TRUE}.} 12 | } 13 | \value{ 14 | Nothing. Text is updated in the active document and footnote is added 15 | to the clipboard if \code{clip = TRUE}. 16 | } 17 | \description{ 18 | Insert a footnote marker with skeleton text. If the user selects some text 19 | before using this function, a modified version of it will be used to fill the 20 | footnote label text instead (punctuation will be removed, spaces will be 21 | replaced by hyphens and the text will be made lowercase). 22 | } 23 | \details{ 24 | The output looks like this if the user hadn't selected any text and just 25 | wants to insert a footnote skeleton: 26 | 27 | \if{html}{\out{
}}\preformatted{Here is some text you wrote [^footnote]. 28 | }\if{html}{\out{
}} 29 | 30 | And the console will print: 31 | 32 | \if{html}{\out{
}}\preformatted{ℹ Copy the footnote '[^footnote]: Insert description'. 33 | ℹ Paste it at the bottom of your document and adjust the description. 34 | ℹ Ensure your footnote labels are unique. 35 | }\if{html}{\out{
}} 36 | 37 | The output looks like this if the user selected some text before using the 38 | function: 39 | 40 | \if{html}{\out{
}}\preformatted{Here is some text[^some-text] you wrote. 41 | }\if{html}{\out{
}} 42 | 43 | And the console will print: 44 | 45 | \if{html}{\out{
}}\preformatted{ℹ The footnote '[^some-text]: Insert description.' was added to the clipboard. 46 | ℹ Paste it at the bottom of your document and adjust the description. 47 | ℹ Ensure your footnote labels are unique. 48 | }\if{html}{\out{
}} 49 | } 50 | \references{ 51 | \href{https://quarto.org/docs/reference/}{The Quarto documentation website.} 52 | } 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # {quartostamp} 3 | 4 | 5 | [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) 6 | [![R-CMD-check](https://github.com/matt-dray/quartostamp/workflows/R-CMD-check/badge.svg)](https://github.com/matt-dray/quartostamp/actions) 7 | 8 | 9 | An R package containing an [RStudio Addin](https://rstudio.github.io/rstudioaddins/) to insert pre-written divs and classes into your [Quarto](https://quarto.org/) documents. 10 | 11 | Why 'quartostamp'? You could physically stamp some pre-prepared type into a [literal quarto document](https://en.wikipedia.org/wiki/Quarto); you can digitally stamp some pre-written elements into your qmd file. 12 | 13 | See the [package website](https://matt-dray.github.io/quartostamp/) for the [full list of available functions](https://matt-dray.github.io/quartostamp/reference/index.html) and the [Quarto website](https://quarto.org/docs/guide/) for full Quarto documentation. 14 | 15 | Please [add requests as GitHub issues](https://github.com/matt-dray/quartostamp/issues), or raise a pull request. 16 | 17 | ## Install and use 18 | 19 | To install this package [from GitHub](https://github.com/matt-dray/quartostamp/), run the following and then restart RStudio: 20 | 21 | ``` r 22 | install.packages("remotes") # if not yet installed 23 | remotes::install_github("matt-dray/quartostamp") 24 | ``` 25 | 26 | To use: 27 | 28 | 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. 29 | 2. Click the 'RStudio Addins' dropdown at the top of the RStudio IDE. 30 | 3. Scroll/search for 'QUARTOSTAMP' and click the function you want. 31 | 32 | Use the help files to learn more about each function. They all start with `stamp_` so you can search like `?stamp_notes`. 33 | 34 | You can also create [custom RStudio keyboard shortcuts](https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts-in-the-RStudio-IDE) for these functions: 35 | 36 | 1. Go to 'Tools' then 'Modify Keyboard Shortcuts...' 37 | 3. Search for the {quartostamp} function that you want a shortcut for. 38 | 4. Click in the 'Shortcut' column and type the key combination you want to use. 39 | 5. Click 'Apply'. 40 | 41 | ## Related 42 | 43 | Other packages can be used alongside {quartostamp} when writing a document: 44 | 45 | * [the {remedy} package](https://thinkr-open.github.io/remedy/) contains an RStudio Addin with a large number of R Markdown helpers, e.g. 'H2' will add leading hashmarks (`##`) to signify a level-two header 46 | * [the {htmltools} package](https://rstudio.github.io/htmltools/) has functions to insert HTML tags, e.g. `tags$h2()` will insert `

` for a level-two header 47 | -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: Insert Aside 2 | Description: Insert a div that creates an 'aside' in a Revealjs presentation slide. 3 | Binding: stamp_aside 4 | Interactive: false 5 | 6 | Name: Insert 'Note' Callout Block 7 | Description: Insert a callout block of type 'note'. 8 | Binding: stamp_callout_note 9 | Interactive: false 10 | 11 | Name: Insert 'Warning' Callout Block 12 | Description: Insert a callout block of type 'warning'. 13 | Binding: stamp_callout_warning 14 | Interactive: false 15 | 16 | Name: Insert 'Important' Callout Block 17 | Description: Insert a callout block of type 'important'. 18 | Binding: stamp_callout_important 19 | Interactive: false 20 | 21 | Name: Insert 'Tip' Callout Block 22 | Description: Insert a callout block of type 'tip'. 23 | Binding: stamp_callout_tip 24 | Interactive: false 25 | 26 | Name: Insert 'Caution' Callout Block 27 | Description: Insert a callout block of type 'caution'. 28 | Binding: stamp_callout_caution 29 | Interactive: false 30 | 31 | Name: Insert Column Layout 32 | Description: Insert a div for a horizontal two-column layout with percentage widths in a Revealjs presentation slide. 33 | Binding: stamp_columns 34 | Interactive: false 35 | 36 | Name: Insert Slide Divider 37 | Description: Insert a slide divider in a Revealjs presentation (for slides without titles) 38 | Binding: stamp_divider 39 | Interactive: false 40 | 41 | Name: Insert Custom Footer 42 | Description: Insert a custom footer div in a Revealjs presentation slide. 43 | Binding: stamp_footer 44 | Interactive: false 45 | 46 | Name: Insert Footnote 47 | Description: Insert a footnote marker in a Revealjs presentation slide. 48 | Binding: stamp_footnote 49 | Interactive: false 50 | 51 | Name: Insert Incremental List 52 | Description: Insert a list-containing div in a Revealjs presentation slide that is revealed incrementally. 53 | Binding: stamp_incremental 54 | Interactive: false 55 | 56 | Name: Insert Non-Incremental List 57 | Description: Insert a list-containing div to a Revealjs presentation slide that is not revealed incrementally (overrides a global incremental reveal). 58 | Binding: stamp_nonincremental 59 | Interactive: false 60 | 61 | Name: Insert Pause 62 | Description: Insert a pause marker into a Revealjs presentation slide. 63 | Binding: stamp_pause 64 | Interactive: false 65 | 66 | Name: Insert Speaker Notes 67 | Description: Insert a speaker notes in a Revealjs presentation slide. 68 | Binding: stamp_notes 69 | Interactive: false 70 | 71 | Name: Insert Smaller Font 72 | Description: Insert a class that makes the font smaller in a Revealjs presentation slide (place on the same line as the slide title). 73 | Binding: stamp_smaller 74 | Interactive: false 75 | 76 | Name: Insert Scrollable Content 77 | Description: Insert a class that allows content to be scrolled if the slide is too small to hold it. 78 | Binding: stamp_scrollable 79 | Interactive: false 80 | 81 | Name: Insert Tabset 82 | Description: Insert a panel tabset div to a Revealjs presentation slide. 83 | Binding: stamp_tabset 84 | Interactive: false 85 | -------------------------------------------------------------------------------- /R/stamps.R: -------------------------------------------------------------------------------- 1 | #' Insert Aside 2 | #' 3 | #' Insert a div that creates an 'aside' in a Revealjs presentation slide. Will 4 | #' embed text selected by the user, otherwise skeleton help text will be 5 | #' inserted. 6 | #' 7 | #' @details 8 | #' The output looks like this if the user hadn't selected any text: 9 | #' ``` 10 | #' ::: aside 11 | #' Additional commentary. 12 | #' ::: 13 | #' 14 | #' ``` 15 | #' 16 | #' @references 17 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 18 | #' 19 | #' @return Nothing. Text is updated in the active document. 20 | #' 21 | #' @export 22 | stamp_aside <- function() { 23 | .replace_text( 24 | pre = "::: aside\n", 25 | body = "Additional commentary.\n", 26 | post = ":::\n" 27 | ) 28 | } 29 | 30 | #' Insert 'Note' Callout Block 31 | #' 32 | #' Insert a callout-block div of type 'note', which has a blue accent and 33 | #' a letter 'i' icon. Will embed text selected bythe user, otherwise 34 | #' skeleton help text will be inserted. 35 | #' 36 | #' @details 37 | #' The output looks like this if the user hadn't selected any text: 38 | #' ``` 39 | #' :::{.callout-note collapse=false appearance='default' icon=true} 40 | #' ## Optional caption (note) 41 | #' - Hide callout body with 'collapse=true' 42 | #' - Remove 'collapse' to prevent expandability 43 | #' - Set appearance to 'default', 'simple' or 'minimal' 44 | #' - Remove icon with 'icon=false' 45 | #' ::: 46 | #' 47 | #' ``` 48 | #' 49 | #' @references 50 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 51 | #' 52 | #' @return Nothing. Text is updated in the active document. 53 | #' 54 | #' @export 55 | stamp_callout_note <- function() { 56 | .insert_callout("note") 57 | } 58 | 59 | #' Insert 'Warning' Callout Block 60 | #' 61 | #' Insert a callout-block div of type 'warning', which has a yellow accent and 62 | #' a warning-triangle icon. Will embed text selected by the user, otherwise 63 | #' skeleton help text will be inserted. 64 | #' 65 | #' @details 66 | #' The output looks like this if the user hadn't selected any text: 67 | #' ``` 68 | #' :::{.callout-warning collapse=false appearance='default' icon=true} 69 | #' ## Optional caption (warning) 70 | #' - Hide callout body with 'collapse=true' 71 | #' - Remove 'collapse' to prevent expandability 72 | #' - Set appearance to 'default', 'simple' or 'minimal' 73 | #' - Remove icon with 'icon=false' 74 | #' ::: 75 | #' 76 | #' ``` 77 | #' 78 | #' @references 79 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 80 | #' 81 | #' @return Nothing. Text is updated in the active document. 82 | #' 83 | #' @export 84 | stamp_callout_warning <- function() { 85 | .insert_callout("warning") 86 | } 87 | 88 | #' Insert 'Important' Callout Block 89 | #' 90 | #' Insert a callout-block div of type 'important', which has a red accent and 91 | #' an exclamation-point icon. Will embed text selected by the user, otherwise 92 | #' skeleton help text will be inserted. 93 | #' 94 | #' @details 95 | #' The output looks like this if the user hadn't selected any text: 96 | #' ``` 97 | #' :::{.callout-important collapse=false appearance='default' icon=true} 98 | #' ## Optional caption (important) 99 | #' - Hide callout body with 'collapse=true' 100 | #' - Remove 'collapse' to prevent expandability 101 | #' - Set appearance to 'default', 'simple' or 'minimal' 102 | #' - Remove icon with 'icon=false' 103 | #' ::: 104 | #' 105 | #' ``` 106 | #' 107 | #' @references 108 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 109 | #' 110 | #' @return Nothing. Text is updated in the active document. 111 | #' 112 | #' @export 113 | stamp_callout_important <- function() { 114 | .insert_callout("important") 115 | } 116 | 117 | #' Insert 'Tip' Callout Block 118 | #' 119 | #' Insert a callout-block div of type 'tip', which has an green accent and 120 | #' a lightbulb icon. Will embed text selected by the user, otherwise skeleton 121 | #' help text will be inserted. 122 | #' 123 | #' @details 124 | #' The output looks like this if the user hadn't selected any text: 125 | #' ``` 126 | #' :::{.callout-tip collapse=false appearance='default' icon=true} 127 | #' ## Optional caption (tip) 128 | #' - Hide callout body with 'collapse=true' 129 | #' - Remove 'collapse' to prevent expandability 130 | #' - Set appearance to 'default', 'simple' or 'minimal' 131 | #' - Remove icon with 'icon=false' 132 | #' ::: 133 | #' 134 | #' ``` 135 | #' 136 | #' @references 137 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 138 | #' 139 | #' @return Nothing. Text is updated in the active document. 140 | #' 141 | #' @export 142 | stamp_callout_tip <- function() { 143 | .insert_callout("tip") 144 | } 145 | 146 | #' Insert 'Caution' Callout Block 147 | #' 148 | #' Insert a callout-block div of type 'caution', which has an orange accent and 149 | #' a traffic-cone icon. Will embed text selected by the user, otherwise skeleton 150 | #' help text will be inserted. 151 | #' 152 | #' @details 153 | #' The output looks like this if the user hadn't selected any text: 154 | #' ``` 155 | #' :::{.callout-caution collapse=false appearance='default' icon=true} 156 | #' ## Optional caption (caution) 157 | #' - Hide callout body with 'collapse=true' 158 | #' - Remove 'collapse' to prevent expandability 159 | #' - Set appearance to 'default', 'simple' or 'minimal' 160 | #' - Remove icon with 'icon=false' 161 | #' ::: 162 | #' 163 | #' ``` 164 | #' 165 | #' @references 166 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 167 | #' 168 | #' @return Nothing. Text is updated in the active document. 169 | #' 170 | #' @export 171 | stamp_callout_caution <- function() { 172 | .insert_callout("caution") 173 | } 174 | 175 | #' Insert Column Layout 176 | #' 177 | #' Insert a div for a horizontal two-column layout with percentage widths in a 178 | #' Revealjs presentation slide. Will embed text selected by the user into the 179 | #' left column and helper text into the right, otherwise skeleton help text will 180 | #' be inserted into both columns. 181 | #' 182 | #' @details 183 | #' The output looks like this if the user hadn't selected any text: 184 | #' ``` 185 | #' :::: {.columns} 186 | #' 187 | #' ::: {.column width='40%'} 188 | #' Left column 189 | #' ::: 190 | #' 191 | #' ::: {.column width='60%'} 192 | #' Right column 193 | #' ::: 194 | #' 195 | #' :::: 196 | #' 197 | #' ``` 198 | #' 199 | #' @references 200 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 201 | #' 202 | #' @return Nothing. Text is updated in the active document. 203 | #' 204 | #' @export 205 | stamp_columns <- function() { 206 | .replace_text( 207 | pre = paste0( 208 | ":::: {.columns}\n", 209 | "\n", 210 | "::: {.column width='40%'}\n" 211 | ), 212 | body = "Left column\n", 213 | post = paste0( 214 | ":::\n", 215 | "\n", 216 | "::: {.column width='60%'}\n", 217 | "Right column\n", 218 | ":::\n", 219 | "\n", 220 | "::::\n" 221 | ) 222 | ) 223 | } 224 | 225 | #' Insert Slide Divider 226 | #' 227 | #' Insert a slide divider in a Revealjs presentation (for slides without 228 | #' titles). 229 | #' 230 | #' @details 231 | #' The output looks like this: 232 | #' ``` 233 | #' --- 234 | #' 235 | #' ``` 236 | #' 237 | #' @references 238 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 239 | #' 240 | #' @return Nothing. Text is updated in the active document. 241 | #' 242 | #' @export 243 | stamp_divider <- function() { 244 | rstudioapi::insertText("---\n") 245 | } 246 | 247 | #' Insert Custom Footer 248 | #' 249 | #' Insert a custom footer div in a Revealjs presentation slide. Will include 250 | #' text selected by the user, otherwise skeleton help text will be inserted. 251 | #' 252 | #' @details 253 | #' The output looks like this if the user hadn't selected any text: 254 | #' ``` 255 | #' ::: footer 256 | #' Custom footer text 257 | #' ::: 258 | #' 259 | #' ``` 260 | #' 261 | #' @references 262 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 263 | #' 264 | #' @return Nothing. Text is updated in the active document. 265 | #' 266 | #' @export 267 | stamp_footer <- function() { 268 | .replace_text( 269 | pre = "::: footer\n", 270 | body = "Custom footer text\n", 271 | post = ":::\n" 272 | ) 273 | } 274 | 275 | #' Insert Footnote 276 | #' 277 | #' Insert a footnote marker with skeleton text. If the user selects some text 278 | #' before using this function, a modified version of it will be used to fill the 279 | #' footnote label text instead (punctuation will be removed, spaces will be 280 | #' replaced by hyphens and the text will be made lowercase). 281 | #' 282 | #' @param clip Logical. Should the footnote string be added to the clipboard so 283 | #' the user can paste it at the bottom of the document? Defaults to `TRUE`. 284 | #' 285 | #' @details 286 | #' The output looks like this if the user hadn't selected any text and just 287 | #' wants to insert a footnote skeleton: 288 | #' ``` 289 | #' Here is some text you wrote [^footnote]. 290 | #' ``` 291 | #' And the console will print: 292 | #' ``` 293 | #' ℹ Copy the footnote '[^footnote]: Insert description'. 294 | #' ℹ Paste it at the bottom of your document and adjust the description. 295 | #' ℹ Ensure your footnote labels are unique. 296 | #' ```` 297 | #' The output looks like this if the user selected some text before using the 298 | #' function: 299 | #' ``` 300 | #' Here is some text[^some-text] you wrote. 301 | #' ``` 302 | #' And the console will print: 303 | #' ``` 304 | #' ℹ The footnote '[^some-text]: Insert description.' was added to the clipboard. 305 | #' ℹ Paste it at the bottom of your document and adjust the description. 306 | #' ℹ Ensure your footnote labels are unique. 307 | #' ```` 308 | #' 309 | #' @references 310 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 311 | #' 312 | #' @return Nothing. Text is updated in the active document and footnote is added 313 | #' to the clipboard if `clip = TRUE`. 314 | #' 315 | #' @export 316 | stamp_footnote <- function(clip = TRUE) { 317 | 318 | if (!inherits(clip, "logical")) { 319 | cli::cli_abort( 320 | c( 321 | "The argument 'clip' must be logical.", 322 | "i" = "Set 'clip' to TRUE or FALSE." 323 | ) 324 | ) 325 | } 326 | 327 | active_doc <- rstudioapi::getActiveDocumentContext() 328 | 329 | if (!is.null(active_doc)) { 330 | 331 | selected_text <- active_doc$selection[[1]]$text 332 | has_selected_text <- nchar(selected_text) > 0 333 | 334 | if (!has_selected_text) { 335 | inline_replace <- "[^footnote]" 336 | foot_insert <- paste0("[^footnote]: Insert description.") 337 | } 338 | 339 | if (has_selected_text) { 340 | selected_depunct <- gsub("[[:punct:]]", "", selected_text) 341 | footnote_label <- gsub("[[:space:]]", "-", tolower(selected_depunct)) 342 | inline_replace <- paste0(selected_text, "[^", footnote_label, "]") 343 | foot_insert <- paste0("[^", footnote_label, "]: Insert description.") 344 | } 345 | 346 | rstudioapi::modifyRange(active_doc$selection[[1]]$range, inline_replace) 347 | 348 | if (clip) { 349 | clipr::write_clip(foot_insert) 350 | cli::cli_alert_info( 351 | paste0("The footnote '", foot_insert, "' was added to the clipboard.") 352 | ) 353 | } 354 | 355 | if (!clip) { 356 | cli::cli_alert_info(paste0("Copy the footnote '", foot_insert, "'.")) 357 | } 358 | 359 | cli::cli_alert_info("Paste it at the bottom of your document and adjust the description.") 360 | cli::cli_alert_info("Ensure your footnote labels are unique.") 361 | 362 | # You can't insert into a new row at the bottom of the document without 363 | # first adding a row and saving over the user's document, which doesn't 364 | # seem like a good idea. For now, use clipr::write_clip() instead.. 365 | # foot_location <- 366 | # rstudioapi::document_position(length(active_doc$contents) + 1, 1) 367 | # rstudioapi::modifyRange(foot_location, text_replace) 368 | 369 | } 370 | 371 | } 372 | 373 | #' Insert Incremental List 374 | #' 375 | #' Insert a list-containing div in a Revealjs presentation slide that is 376 | #' revealed incrementally. Will embed text selected by the user, otherwise 377 | #' skeleton help text will be inserted. 378 | #' 379 | #' @details 380 | #' The output looks like this if the user hadn't selected any text: 381 | #' ``` 382 | #' ::: {.incremental} 383 | #' - List element A 384 | #' - List element B 385 | #' ::: 386 | #' 387 | #' ``` 388 | #' 389 | #' @references 390 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 391 | #' 392 | #' @return Nothing. Text is updated in the active document. 393 | #' 394 | #' @export 395 | stamp_incremental <- function() { 396 | .replace_text( 397 | pre = "::: {.incremental}\n", 398 | body = paste0( 399 | "- List element A\n", 400 | "- List element B\n" 401 | ), 402 | post = ":::\n" 403 | ) 404 | } 405 | 406 | #' Insert Non-Incremental List 407 | #' 408 | #' Insert a list-containing div to a Revealjs presentation slide that is not 409 | #' revealed incrementally (overrides a global incremental reveal). Will embed 410 | #' text selected by the user, otherwise skeleton help text will be inserted. 411 | #' 412 | #' @details 413 | #' The output looks like this if the user hadn't selected any text: 414 | #' ``` 415 | #' ::: {.nonincremental} 416 | #' - List element A 417 | #' - List element B 418 | #' ::: 419 | #' 420 | #' ``` 421 | #' 422 | #' @references 423 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 424 | #' 425 | #' @return Nothing. Text is updated in the active document. 426 | #' 427 | #' @export 428 | stamp_nonincremental <- function() { 429 | .replace_text( 430 | pre = "::: {.nonincremental}\n", 431 | body = paste0( 432 | "- List element A\n", 433 | "- List element B\n" 434 | ), 435 | post = ":::\n" 436 | ) 437 | } 438 | 439 | #' Insert Pause 440 | #' 441 | #' Insert a pause marker into a Revealjs presentation slide. 442 | #' 443 | #' @details 444 | #' The output looks like this: 445 | #' ``` 446 | #' . . . 447 | #' 448 | #' ``` 449 | #' 450 | #' @references 451 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 452 | #' 453 | #' @return Nothing. Text is updated in the active document. 454 | #' 455 | #' @export 456 | stamp_pause <- function() { 457 | rstudioapi::insertText(". . .\n") 458 | } 459 | 460 | #' Insert Speaker Notes 461 | #' 462 | #' Insert a speaker notes div in a Revealjs presentation slide. Will embed 463 | #' text selected by the user, otherwise skeleton help text will be inserted. 464 | #' 465 | #' @details 466 | #' The output looks like this if the user hadn't selected any text: 467 | #' ``` 468 | #' ::: {.notes} 469 | #' Speaker notes (press 's' when presenting to switch to speaker mode). 470 | #' ::: 471 | #' 472 | #' ``` 473 | #' 474 | #' @references 475 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 476 | #' 477 | #' @return Nothing. Text is updated in the active document. 478 | #' 479 | #' @export 480 | stamp_notes <- function() { 481 | .replace_text( 482 | pre = "::: {.notes}\n", 483 | body = "Speaker notes (press 's' when presenting to switch to speaker mode).\n", 484 | post = ":::\n" 485 | ) 486 | } 487 | 488 | #' Insert Smaller Font 489 | #' 490 | #' Insert a class that makes the font smaller in a Revealjs presentation slide 491 | #' (place on the same line as the slide title). 492 | #' 493 | #' @details 494 | #' Output looks like this: 495 | #' ``` 496 | #' {.smaller} 497 | #' ``` 498 | #' 499 | #' @references 500 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 501 | #' 502 | #' @return Nothing. Text is updated in the active document. 503 | #' 504 | #' @export 505 | stamp_smaller <- function() { 506 | rstudioapi::insertText("{.smaller}") 507 | } 508 | 509 | #' Insert Scrollable Content 510 | #' 511 | #' Insert a class that allows content to be scrolled if the slide is too small 512 | #' to hold it (place on the same line as the slide title). 513 | #' 514 | #' @details 515 | #' Output looks like this: 516 | #' ``` 517 | #' {.scrollable} 518 | #' ``` 519 | #' 520 | #' @references 521 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 522 | #' 523 | #' @return Nothing. Text is updated in the active document. 524 | #' 525 | #' @export 526 | stamp_scrollable <- function() { 527 | rstudioapi::insertText("{.scrollable}") 528 | } 529 | 530 | #' Insert Tabset 531 | #' 532 | #' Insert a panel tabset div to a Revealjs presentation slide. Will embed text 533 | #' selected by the user into the first tab and skeleton help text into the 534 | #' second, otherwise skeleton help text will be inserted into both tabs. 535 | #' 536 | #' @details 537 | #' The output looks like this if the user hadn't selected any text: 538 | #' ``` 539 | #' ::: {.panel-tabset} 540 | #' 541 | #' ## Tab A 542 | #' 543 | #' Content for Tab A 544 | #' 545 | #' ## Tab B 546 | #' 547 | #' Content for Tab B 548 | #' 549 | #' ::: 550 | #' 551 | #' ``` 552 | #' 553 | #' @references 554 | #' [The Quarto documentation website.](https://quarto.org/docs/reference/) 555 | #' 556 | #' @return Nothing. Text is updated in the active document. 557 | #' 558 | #' @export 559 | stamp_tabset <- function() { 560 | .replace_text( 561 | pre = paste0( 562 | "::: {.panel-tabset}\n", 563 | "\n", 564 | "## Tab A\n", 565 | "\n" 566 | ), 567 | body = "Content for Tab A\n", 568 | post = paste0( 569 | "\n", 570 | "## Tab B\n", 571 | "\n", 572 | "Content for Tab B\n", 573 | "\n", 574 | ":::\n" 575 | ) 576 | ) 577 | } 578 | --------------------------------------------------------------------------------