These function can be used to convert one or more parsed sources to HTML, or to convert all sources to tabbed sections in Markdown.
Usage
export_codes_to_txt(
input,
output = NULL,
codeTree = "fullyMergedCodeTrees",
codingScheme = "codes",
regex = ".*",
onlyChildrenOf = NULL,
leavesOnly = TRUE,
includePath = TRUE,
preventOverwriting = rock::opts$get(preventOverwriting),
encoding = rock::opts$get(encoding),
silent = rock::opts$get(silent)
)Arguments
- input
An object of class
rock_parsedSource(as resulting from a call toparse_source) or of classrock_parsedSources(as resulting from a call toparse_sources.- output
THe filename to write to.
- codeTree
Codes from which code tree to export the codes. Valid options are
fullyMergedCodeTrees,extendedDeductiveCodeTrees,deductiveCodeTrees, andinductiveCodeTrees.- codingScheme
With the ROCK, it's possible to use multiple coding scheme's in parallel. The ROCK default is called
codes(using the double square brackets as code delimiters), but other delimiters can be used as well, and give a different name. UsecodingSchemeto specify which code tree you want to export, if you have multiple.- regex
An optional regular expression: only codes matching this regular expression will be selected.
- onlyChildrenOf
A character vector of one or more regular expressions that specify codes within which to search. For example, if the code tree contains codes
parent1andparent2, and each have a number of child codes, andparentis passed asonlyChildrenOf, only the codes withinparentare selected.- leavesOnly
Whether to only write the leaves (i.e. codes that don't have children) or all codes in the code tree.
- includePath
Whether to only return the code itself (e.g.
code) or also include the path to the root (e.g.code1>code2>code).- preventOverwriting
Whether to prevent overwriting of output files.
- encoding
The encoding to use when writing the exported source(s).
- silent
Whether to suppress messages.
Examples
### Get path to example source
examplePath <-
system.file("extdata", package="rock");
### Parse a selection of example sources in that directory
parsedExamples <-
rock::parse_sources(
examplePath,
regex = "(test|example)(.txt|.rock)"
);
#> Error in rock::parse_source(file = filename, ignoreOddDelimiters = ignoreOddDelimiters, encoding = encoding, postponeDeductiveTreeBuilding = TRUE, removeSectionBreakRows = removeSectionBreakRows, removeIdentifierRows = removeIdentifierRows, filesWithYAML = filesWithYAML, removeEmptyRows = removeEmptyRows, mergeAttributes = FALSE, silent = silent): object 'notes' not found
### Show results of exporting the codes
rock::export_codes_to_txt(parsedExamples);
#> Error: object 'parsedExamples' not found
### Only show select a narrow set of codes
rock::export_codes_to_txt(
parsedExamples,
leavesOnly=TRUE,
includePath=FALSE,
onlyChildrenOf = "inductFather",
regex="3|5"
);
#> Error: object 'parsedExamples' not found
