Learn R Programming

quartose (version 0.1.0)

quarto_print: Print a quarto object

Description

Prints a quarto object. When calling knitr::knit_print() on a quarto object, the relevant format() method is called first, and the formatted version is printed to the document. When calling print(), a summary of the object structure is printed.

Usage

# S3 method for quarto_object
knit_print(x, ...)

# S3 method for quarto_object print(x, ...)

Value

knitr::knit_print() invisibly returns NULL; print()

invisibly returns the quarto object itself.

Arguments

x

A quarto object.

...

Other arguments (ignored).

Details

There are two print methods supplied for quarto objects, one for base::print() and another for knitr::knit_print(). The regular print method behaves similarly to any other print method: it prints a summary of the object to the R console, and invisibly returns the object itself.

When knitr::knit_print() is called on a quarto object, the behavior is quite different. The object is first passed to format(), which constructs the required quarto syntax, then the object is printed to the document (or console, if called interactively) using the appropriate syntax. In this case, the function invisibly returns NULL.

Examples

Run this code
# a quarto_section object
sec <- quarto_section("A level-two header", level = 2L)
 
# base::print() displays a summary of the object 
print(sec)

# knitr::knit_print() displays the rendered quarto syntax
knitr::knit_print(sec) 

# a quarto_span object
spn <- quarto_span("This is underlined", class = "underline")

print(spn)

knitr::knit_print(spn)
 

Run the code above in your browser using DataLab