to_xml {tinkr} | R Documentation |
Transform file to XML
Description
Transform file to XML
Usage
to_xml(
path,
encoding = "UTF-8",
sourcepos = FALSE,
anchor_links = TRUE,
unescaped = TRUE
)
Arguments
path |
Path to the file. |
encoding |
Encoding to be used by readLines. |
sourcepos |
passed to |
anchor_links |
if |
unescaped |
if |
Details
This function will take a (R)markdown file, split the yaml header
from the body, and read in the body through commonmark::markdown_xml()
.
Any RMarkdown code fences will be parsed to expose the chunk options in
XML and tickboxes (aka checkboxes) in GitHub-flavored markdown will be
preserved (both modifications from the commonmark standard).
Value
A list containing the YAML of the file (yaml) and its body (body) as XML.
Note
Math elements are not protected by default. You can use protect_math()
to
address this if needed.
Examples
path <- system.file("extdata", "example1.md", package = "tinkr")
post_list <- to_xml(path)
names(post_list)
path2 <- system.file("extdata", "example2.Rmd", package = "tinkr")
post_list2 <- to_xml(path2)
post_list2