to_md {tinkr} | R Documentation |
Write YAML and XML back to disk as (R)Markdown
Description
Write YAML and XML back to disk as (R)Markdown
Usage
to_md(yaml_xml_list, path = NULL, stylesheet_path = stylesheet())
Arguments
yaml_xml_list |
result from a call to |
path |
path of the new file. Defaults to |
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.
Value
the converted document, invisibly.
Examples
path <- system.file("extdata", "example1.md", package = "tinkr")
yaml_xml_list <- to_xml(path)
names(yaml_xml_list)
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
newmd <- tempfile("newmd", fileext = ".md")
to_md(yaml_xml_list, newmd)
# file.edit("newmd.md")
file.remove(newmd)
[Package tinkr version 0.2.0 Index]