Title: | Programmatic Element Creation For Quarto Documents |
---|---|
Description: | Programatically generate quarto-compliant markdown elements. |
Authors: | Elian Thiele-Evans [aut, cre] , Eli Pousson [aut] |
Maintainer: | Elian Thiele-Evans <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.0.9000 |
Built: | 2024-11-21 04:35:00 UTC |
Source: | https://github.com/ElianHugh/quartools |
map_qto()
loops a list over a package function defined by .type or a custom
function that returns a quarto block output. This function always returns a
list of quarto block objects.
map_qto( .x, .f = NULL, ..., .type = c("block", "div", "callout", "heading"), .sep = "", .collapse = "", call = caller_env() )
map_qto( .x, .f = NULL, ..., .type = c("block", "div", "callout", "heading"), .sep = "", .collapse = "", call = caller_env() )
.x |
An input vector. |
.f |
Optional function to apply to each element. If function does not
return a "quarto_block" class object, the output is passed to |
... |
Additional parameters passed to function defined by |
.type |
If .f is |
.sep , .collapse
|
Additional parameters passed to |
call |
The execution environment of a currently
running function, e.g. |
qto_list <- map_qto( list("This is a note.", "And this is a note.", "And this is a note"), .type = "callout" ) qto_block(qto_list)
qto_list <- map_qto( list("This is a note.", "And this is a note.", "And this is a note"), .type = "callout" ) qto_block(qto_list)
pmap_qto()
loops a list of vectors over a package function defined by .type or a custom
function that returns a quarto block output. This function always returns a
list of quarto block objects.
pmap_qto( .l, .f = NULL, ..., .type = c("block", "div", "callout", "heading"), .sep = "", .collapse = "", call = caller_env() )
pmap_qto( .l, .f = NULL, ..., .type = c("block", "div", "callout", "heading"), .sep = "", .collapse = "", call = caller_env() )
.l |
An input vector. |
.f |
Optional function to apply to each element. If function does not
return a "quarto_block" class object, the output is passed to |
... |
Additional parameters passed to function defined by |
.type |
If .f is |
.sep , .collapse
|
Additional parameters passed to |
call |
The execution environment of a currently
running function, e.g. |
qto_list <- pmap_qto( list( list("Answer:", "Answer:", "Answer:"), list("Yes", "No", "Yes") ) ) qto_block(qto_list) qto_list <- pmap_qto( mtcars[seq(3L), seq(3L)], function(mpg, cyl, disp) { qto_li( .list = list( sprintf("mpg is: %s", mpg), sprintf("cyl is: %s", cyl), sprintf("disp is: %s", disp) ) ) } ) qto_block(qto_list)
qto_list <- pmap_qto( list( list("Answer:", "Answer:", "Answer:"), list("Yes", "No", "Yes") ) ) qto_block(qto_list) qto_list <- pmap_qto( mtcars[seq(3L), seq(3L)], function(mpg, cyl, disp) { qto_li( .list = list( sprintf("mpg is: %s", mpg), sprintf("cyl is: %s", cyl), sprintf("disp is: %s", disp) ) ) } ) qto_block(qto_list)
qto_attributes()
creates an attribute string used by qto_div()
,
qto_span()
, or qto_fig_span()
.
qto_attributes( id = NULL, class = NULL, css = NULL, ..., .attributes = NULL, .output = "embrace", .drop_empty = TRUE, call = caller_env() )
qto_attributes( id = NULL, class = NULL, css = NULL, ..., .attributes = NULL, .output = "embrace", .drop_empty = TRUE, call = caller_env() )
id |
Div or span identifier. If |
class |
Div or span class. If |
css |
If |
... |
Optional named attributes. |
.attributes |
Optional list of attributes. If supplied, any attributes
passed to |
.output |
Output type. If "embrace", the returned attributes are always enclosed in curly brackets, e.g. "" if no attributes are supplied. If "span", an empty string is returned if no attributes are provided. |
.drop_empty |
If |
call |
The execution environment of a currently
running function, e.g. |
qto_attributes(id = "id", class = "class") qto_attributes(class = "class", key1 = "val", key2 = "val") qto_attributes(width = 4)
qto_attributes(id = "id", class = "class") qto_attributes(class = "class", key1 = "val", key2 = "val") qto_attributes(width = 4)
qto_heading()
creates headings and qto_hr()
creates horizontal rules.
qto_heading(..., level = 1L) qto_hr(rule = "-", length = 72L, before = "\n\n", after = before)
qto_heading(..., level = 1L) qto_hr(rule = "-", length = 72L, before = "\n\n", after = before)
... |
Heading text passed sto |
level |
Heading level. Defaults to 1. |
rule , length
|
Horizontal rule character and length of rule. |
before , after
|
Text to insert before and after a horizontal rule. |
qto_block()
passes the input to paste()
and assigns the classes
"knit_asis" and "quarto_block".
qto_block(..., sep = "", collapse = "", call = caller_env())
qto_block(..., sep = "", collapse = "", call = caller_env())
... |
dots to convert to character vector |
sep |
a character string to separate the terms. Not
|
collapse |
an optional character string to separate the results. Not
|
call |
The execution environment of a currently
running function, e.g. |
character vector of length 1
qto_block("Hello world!") qto_block("Hello", "world!", sep = " ") qto_block("- ", LETTERS[1:4], collapse = "\n")
qto_block("Hello world!") qto_block("Hello", "world!", sep = " ") qto_block("- ", LETTERS[1:4], collapse = "\n")
Callouts are an excellent way to draw extra attention to certain concepts, or to more clearly indicate that certain content is supplemental or applicable to only some scenarios. https://quarto.org/docs/authoring/callouts.html
qto_callout( ..., type = c("note", "tip", "warning", "caution", "important"), collapse = NULL, appearance = NULL, icon = NULL, title = NULL, id = NULL, class = NULL, .attributes = NULL, call = caller_env() )
qto_callout( ..., type = c("note", "tip", "warning", "caution", "important"), collapse = NULL, appearance = NULL, icon = NULL, title = NULL, id = NULL, class = NULL, .attributes = NULL, call = caller_env() )
... |
Arguments passed on to
|
type |
Callout type. One of "note", "tip", "warning", "caution", or "important". https://quarto.org/docs/authoring/callouts.html#callout-types |
collapse |
If |
appearance |
Callout appearance. One of "default", "simple", "minimal". https://quarto.org/docs/authoring/callouts.html#appearance |
icon |
If |
title |
Title attribute. Works the same as included a level 2 heading before the body of the callout contents. |
id |
Div or span identifier. If |
class |
Div or span class. If |
.attributes |
Optional list of attributes. If supplied, any attributes
passed to |
call |
The execution environment of a currently
running function, e.g. |
qto_callout( "Callouts provide a simple way to attract attention, for example, to this warning.", type = "warning" ) qto_callout( "This is an example of a callout with a title.", type = "tip", title = "Tip with a title" )
qto_callout( "Callouts provide a simple way to attract attention, for example, to this warning.", type = "warning" ) qto_callout( "This is an example of a callout with a title.", type = "tip", title = "Tip with a title" )
https://quarto.org/docs/authoring/markdown-basics.html#divs-and-spans
qto_div( ..., id = NULL, class = NULL, css = NULL, .attributes = NULL, .content = NULL, collapse = "", drop_empty = TRUE, drop_na = TRUE, call = caller_env() )
qto_div( ..., id = NULL, class = NULL, css = NULL, .attributes = NULL, .content = NULL, collapse = "", drop_empty = TRUE, drop_na = TRUE, call = caller_env() )
... |
Optional named attributes. |
id |
Div or span identifier. If |
class |
Div or span class. If |
css |
If |
.attributes |
Optional list of attributes. If supplied, any attributes
passed to |
.content |
If |
collapse |
Passed to |
drop_empty |
If |
drop_na |
If |
call |
The execution environment of a currently
running function, e.g. |
# div with an class qto_div( "This content can be styled with a border", class = "border" ) # Nested div qto_div( qto_div("Here is a warning.", class = "warning"), "More content.", id = "special", class = "sidebar" )
# div with an class qto_div( "This content can be styled with a border", class = "border" ) # Nested div qto_div( qto_div("Here is a warning.", class = "warning"), "More content.", id = "special", class = "sidebar" )
See the Quarto documentation for more information on lists: https://quarto.org/docs/authoring/markdown-basics.html#lists
qto_dl( ..., .term = NULL, .definition = NULL, .list = NULL, .drop_na = FALSE, .sep = "\n", .replacement = "" )
qto_dl( ..., .term = NULL, .definition = NULL, .list = NULL, .drop_na = FALSE, .sep = "\n", .replacement = "" )
... |
Optional. Named argument where the argument name is a term and the
value name is the text to display as a definition for the term. Ignored if
|
.term , .definition
|
If supplied, |
.list |
If |
.drop_na |
If |
.sep |
Added separator string between terms and definitions. Defaults to
|
.replacement |
If not |
qto_dl( "Quarto" = "An open-source scientific and technical publishing system" ) qto_dl( .term = "Quarto", .definition = "An open-source scientific and technical publishing system" ) qto_dl( .list = list("Quarto" = "An open-source scientific and technical publishing system") )
qto_dl( "Quarto" = "An open-source scientific and technical publishing system" ) qto_dl( .term = "Quarto", .definition = "An open-source scientific and technical publishing system" ) qto_dl( .list = list("Quarto" = "An open-source scientific and technical publishing system") )
qto_fig()
creates Markdown formatting to insert a figure or image. Learn
more about figure formatting options in the Quarto documentation:
https://quarto.org/docs/authoring/figures.html Note that LaTeX output
formats may not support external images:
https://tex.stackexchange.com/questions/5433/can-i-use-an-image-located-on-the-web-in-a-latex-document
qto_fig( src, caption = NULL, alt = NULL, reference = NULL, align = NULL, pos = NULL, width = NULL, height = NULL, title = NULL, ..., allow_missing = TRUE )
qto_fig( src, caption = NULL, alt = NULL, reference = NULL, align = NULL, pos = NULL, width = NULL, height = NULL, title = NULL, ..., allow_missing = TRUE )
src |
Figure file path or URL. |
caption |
Figure caption. |
alt |
Figure alt text. |
reference |
Figure reference. "fig-" prefix is optional. |
align , pos , width , height
|
Figure alignment, position, width, and height. |
title |
Figure title. |
... |
Additional attributes passed to attributes argument of
|
allow_missing |
If |
Other span:
qto_link()
,
qto_span()
qto_fig("image.jpeg", "Image caption", alt = "Image alt text") qto_fig("graphic.pdf", title = "Title of the graphic")
qto_fig("image.jpeg", "Image caption", alt = "Image alt text") qto_fig("graphic.pdf", title = "Title of the graphic")
Create a Markdown link
qto_link(src, text = NULL, ..., allow_empty = FALSE, call = caller_env())
qto_link(src, text = NULL, ..., allow_empty = FALSE, call = caller_env())
src |
Path or URL for link. Required. |
text |
Optional link text. If link text is not provided, a bare link,
e.g. |
... |
Arguments passed on to
|
allow_empty |
If |
call |
The execution environment of a currently
running function, e.g. |
Other span:
qto_fig()
,
qto_span()
qto_link("https://quarto.org") qto_link("https://quarto.org", "Quarto") qto_link("https://quarto.org", "Quarto", class = "smaller")
qto_link("https://quarto.org") qto_link("https://quarto.org", "Quarto") qto_link("https://quarto.org", "Quarto", class = "smaller")
qto_ol()
created ordered lists and qto_li()
creates unordered lists. See
the Quarto documentation for more information on lists:
https://quarto.org/docs/authoring/markdown-basics.html#lists
qto_ol(.list = NULL, ..., level = 1L, symbol = "1.") qto_li(.list = NULL, ..., level = 1L, symbol = "*", sep = "")
qto_ol(.list = NULL, ..., level = 1L, symbol = "1.") qto_li(.list = NULL, ..., level = 1L, symbol = "*", sep = "")
.list |
A vector of list items. Optional if items are passed to |
... |
Items to use as list items. Ignored if .list is supplied. |
level |
Indent level of list. Nested levels in a single function call are not yet supported. |
symbol |
Symbol to use for list bullet. Use "(@)" to create a list where numbering continues after interruption. |
sep |
Separator character between list items passed to |
qto_ol(LETTERS[1:2]) qto_li(LETTERS[3:4]) qto_li(LETTERS[5:6], level = 2) qto_ol(LETTERS[7:8], sep = "\n") qto_li(LETTERS[5:6], symbol = c("*", " +"))
qto_ol(LETTERS[1:2]) qto_li(LETTERS[3:4]) qto_li(LETTERS[5:6], level = 2) qto_ol(LETTERS[7:8], sep = "\n") qto_li(LETTERS[5:6], symbol = c("*", " +"))
qto_shortcode()
creates a shortcode based on an input string.
qto_shortcode(x, before = "{{< ", after = " >}}", ...) qto_video(src) qto_pagebreak() qto_kbd(...)
qto_shortcode(x, before = "{{< ", after = " >}}", ...) qto_video(src) qto_pagebreak() qto_kbd(...)
x |
An input string. |
before , after
|
Text to insert before and after the supplied string. |
... |
For |
src |
For |
qto_video("https://www.youtube.com/embed/wo9vZccmqwc") qto_pagebreak() qto_kbd("Shift", "Ctrl", "P") qto_kbd( mac = "Shift-Command-O", win = "Shift-Control-O", linux = "Shift-Ctrl-L" )
qto_video("https://www.youtube.com/embed/wo9vZccmqwc") qto_pagebreak() qto_kbd("Shift", "Ctrl", "P") qto_kbd( mac = "Shift-Command-O", win = "Shift-Control-O", linux = "Shift-Ctrl-L" )
See the Quarto documentation for more on divs and spans: https://quarto.org/docs/authoring/markdown-basics.html#divs-and-spans
qto_span(text, ..., .attributes = NULL)
qto_span(text, ..., .attributes = NULL)
text |
Text to wrap in span bracket. |
... |
Arguments passed on to
|
.attributes |
Optional list of attributes. If supplied, any attributes
passed to |
Other span:
qto_fig()
,
qto_link()
qto_span("This is *some text*", class = "class", key = "value") qto_span("This is good", id = "id", class = "class", key1 = "val1", key2 = "val2")
qto_span("This is *some text*", class = "class", key = "value") qto_span("This is good", id = "id", class = "class", key1 = "val1", key2 = "val2")
Create a div block that modifies the current quarto layout column temporarily.
See the Quarto documentation for a full list of available extension options.
with_body_column( ..., outset = FALSE, id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_page_column( ..., id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_screen_inset_column( ..., id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_screen_column( ..., id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_margin_column(..., id = NULL, .attributes = NULL, call = caller_env())
with_body_column( ..., outset = FALSE, id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_page_column( ..., id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_screen_inset_column( ..., id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_screen_column( ..., id = NULL, class = NULL, extension = NULL, .attributes = NULL, call = caller_env() ) with_margin_column(..., id = NULL, .attributes = NULL, call = caller_env())
... |
Arguments passed on to
|
outset |
If |
id |
Div or span identifier. If |
class |
Div or span class. If |
extension |
affix to apply to column class |
.attributes |
Optional list of attributes. If supplied, any attributes
passed to |
call |
The execution environment of a currently
running function, e.g. |
character vector of length 1
with_body_column("Hello world!")
with_body_column("Hello world!")