Transform file to XML

to_xml(path, encoding = "UTF-8")

Arguments

path

Path to the file.

encoding

Encoding to be used by readLines.

Value

A list containing the YAML of the file (yaml) and its body (body) as XML.

Examples

path <- system.file("extdata", "example1.md", package = "tinkr") post_list <- to_xml(path) names(post_list)
#> [1] "yaml" "body"
path2 <- system.file("extdata", "example2.Rmd", package = "tinkr") post_list2 <- to_xml(path2) post_list2
#> $yaml #> [1] "---" "title: \"Untitled\"" #> [3] "author: \"M. Salmon\"" "date: \"September 6, 2018\"" #> [5] "output: html_document" "---" #> #> $body #> {xml_document} #> <document xmlns="http://commonmark.org/xml/1.0"> #> [1] <code_block xml:space="preserve" language="r" name="setup" include="FALS ... #> [2] <heading level="2">\n <text xml:space="preserve">R Markdown</text>\n</h ... #> [3] <paragraph>\n <text xml:space="preserve">This is an </text>\n <striket ... #> [4] <paragraph>\n <text xml:space="preserve">When you click the </text>\n ... #> [5] <code_block xml:space="preserve" language="r" name="" eval="TRUE" echo=" ... #> [6] <heading level="2">\n <text xml:space="preserve">Including Plots</text> ... #> [7] <paragraph>\n <text xml:space="preserve">You can also embed plots, for ... #> [8] <code_block xml:space="preserve" language="python" name="" fig.cap="&quo ... #> [9] <code_block xml:space="preserve" language="python" name="">plot(pressure ... #> [10] <paragraph>\n <text xml:space="preserve">Note that the </text>\n <code ... #> [11] <table>\n <table_header>\n <table_cell align="left">\n <text xm ... #> [12] <paragraph>\n <text xml:space="preserve">blabla</text>\n</paragraph> #>