Write YAML and XML back to disk as (R)Markdown

to_md(yaml_xml_list, path, stylesheet_path = system.file("extdata",
  "xml2md_gfm.xsl", package = "tinkr"))

Arguments

yaml_xml_list

result from a call to to_xml and editing.

path

path of the new file

stylesheet_path

path to the XSL stylesheet

Details

The stylesheet you use will decide whether lists are built using "*" or "-" for instance. If you're keen to keep your own Markdown style when using to_md after to_xml, you can tweak the XSL stylesheet a bit and provide the path to your XSL stylesheet as argument.

Examples

path <- system.file("extdata", "example1.md", package = "tinkr") yaml_xml_list <- to_xml(path) names(yaml_xml_list)
#> [1] "yaml" "body"
library("magrittr") # transform level 3 headers into level 1 headers body <- yaml_xml_list$body body %>% xml2::xml_find_all(xpath = './/d1:heading', xml2::xml_ns(.)) %>% .[xml2::xml_attr(., "level") == "3"] -> headers3 xml2::xml_set_attr(headers3, "level", 1) yaml_xml_list$body <- body # save back and have a look to_md(yaml_xml_list, "newmd.md") # file.edit("newmd.md")