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 class 'quarto_object'
knit_print(x, ...)
# S3 method for class 'quarto_object'
print(x, ...)
Value
knitr::knit_print()
invisibly returns NULL
; print()
invisibly returns the quarto object itself.
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
# a quarto_section object
sec <- quarto_section("A level-two header", level = 2L)
# base::print() displays a summary of the object
print(sec)
#> <quarto_section>
#> • title: A level-two header
#> • level: 2
# knitr::knit_print() displays the rendered quarto syntax
knitr::knit_print(sec)
#>
#>
#> ## A level-two header
#>
#>
# a quarto_span object
spn <- quarto_span("This is underlined", class = "underline")
print(spn)
#> <quarto_span>
#> • content: This is underlined
#> • class: underline
#> • sep:
knitr::knit_print(spn)
#> [This is underlined]{.underline}