These function can be used to convert one or more parsed sources to HTML, or to convert all sources to tabbed sections in Markdown.

export_to_html(
  input,
  output = NULL,
  template = "default",
  fragment = FALSE,
  preventOverwriting = rock::opts$get(preventOverwriting),
  encoding = rock::opts$get(encoding),
  silent = rock::opts$get(silent)
)

export_to_markdown(
  input,
  heading = "Sources",
  headingLevel = 2,
  template = "default",
  silent = rock::opts$get(silent)
)

Arguments

input

An object of class rockParsedSource (as resulting from a call to parse_source) or of class rockParsedSources (as resulting from a call to parse_sources.

output

For export_to_html, either NULL to not write any files, or, if input is a single rockParsedSource, the filename to write to, and if input is a rockParsedSources object, the path to write to. This path will be created with a warning if it does not exist.

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.

fragment

Whether to include the CSS and HTML tags (FALSE) or just return the fragment(s) with the source(s) (TRUE).

preventOverwriting

For export_to_html, whether to prevent overwriting of output files.

encoding

For export_to_html, the encoding to use when writing the exported source(s).

silent

Whether to suppress messages.

heading, headingLevel

For

Value

A character vector or a list of character vectors.

Examples

### Get path to example source examplePath <- system.file("extdata", package="rock"); ### Parse all example sources in that directory parsedExamples <- rock::parse_sources(examplePath); ### Export results to a temporary directory tmpDir <- tempdir(check = TRUE); prettySources <- export_to_html(input = parsedExamples, output = tmpDir); ### Show first one print(prettySources[[1]]);
#> [1] "\n<html><head>\n\n<style\n>\n\n.code {\n border-radius: .25em;\n box-sizing: border-box;\n margin-left: 10px;\n padding: 2px;\n}\n\n.identifier {\n border-radius: .25em;\n box-sizing: border-box;\n margin-left: 10px;\n padding: 2px;\n}\n\n.sectionBreak {\n border-radius: .25em;\n box-sizing: border-box;\n display: block;\n}\n\n.uid {\n border-radius: 0;\n box-sizing: border-box;\n}\n\n.utterance {\n display: block;\n}\n\n.code {\n background-color: #f4d142;\n}\n\n.identifier {\n background-color: #aaaaff;\n}\n\n.sectionBreak {\n background-color: #eeeeff;\n}\n\n.uid {\n background-color: #eeeeee;\n color: #bbbbbb;\n}\n\n.utterance {\n border-top: 1px dotted black;\n border-bottom: 1px dotted black;\n}\n\n.utterance + .utterance {\n margin-top: -1px;\n}\n</style>\n\n</head><body>\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n</body></html>\n"