View source: R/prettify_source.R
prettify_source | R Documentation |
This function adds HTML tags to a source to allow pretty printing/viewing. For an example, visit https://rock.opens.science/articles/rock.html.
prettify_source(
x,
heading = NULL,
headingLevel = 2,
add_html_tags = TRUE,
output = NULL,
outputViewer = "viewer",
template = "default",
includeCSS = TRUE,
preserveSpaces = TRUE,
includeBootstrap = rock::opts$get("includeBootstrap"),
preventOverwriting = rock::opts$get(preventOverwriting),
silent = rock::opts$get(silent)
)
x |
The source, as imported with |
heading |
Optionally, a title to include in the output. The title
will be prefixed with |
headingLevel |
The number of hashes to insert before the headings. |
add_html_tags |
Whether to add HTML tags to the result. |
output |
Here, a path and filename can be provided where the result will be written. If provided, the result will be returned invisibly. |
outputViewer |
If showing output, where to show the output: in
the console ( |
template |
The template to load; either the name of one of the ROCK templates (currently, only 'default' is available), or the path and filename of a CSS file. |
includeCSS |
Whether to include the ROCK CSS in the returned HTML. |
preserveSpaces |
Whether to preservce spaces (by replacing every second
space with |
includeBootstrap |
Whether to include the default bootstrap CSS. |
preventOverwriting |
Whether to prevent overwriting of output files. |
silent |
Whether to provide ( |
A character vector with the prettified source
### Get path to example source
examplePath <-
system.file("extdata", package="rock");
### Get a path to one example file
exampleFile <-
file.path(examplePath, "example-1.rock");
### Prettify source; if using RStudio, by default the
### prettified source is shown in the viewer. You can
### view the output of this example in the "rock" vignette
### at https://rock.opens.science/articles/rock.html
rock::prettify_source(
exampleFile
);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.