mdweave {simplermarkdown} | R Documentation |
Run the code in a markdown file and generate a new markdown file
Description
Run the code in a markdown file and generate a new markdown file
Usage
mdweave(
fn,
ofn = file_subs_ext(basename(fn), ".md", FALSE),
cmd1 = "pandoc -s \"%1$s\" -t json -o \"%2$s\"",
cmd2 = "pandoc -s \"%1$s\" -t markdown%3$s -o \"%2$s\"",
...
)
Arguments
fn |
filename of the markdown file (should use pandoc markdown). |
ofn |
name of the resulting markdown file. |
cmd1 |
command used to run pandoc. See details. |
cmd2 |
command used to run pandoc. See details. |
... |
ignored |
Details
mdweave
calls pandoc twice. In the first call the markdown file is
parsed by pandoc and the parse tree is written to a temporary file. This
parse tree is the read by mdweave and any R-code in the tree is executed
resulting in a modified parse tree. This file is then stored to a new
temporary file. Pandoc is the called a second time to convert the new
parse tree to a markdown file.
The arguments cmd1
and cmd2
contain the calls used to run
pandoc. The arguments can be used to, for example pas additional arguments
to pandoc. They use positional arguments. In cmd1
, the first argument
(%1$s
) is the input file name and the second (%2$s
) the
temporary file containing the parsed tree. In cmd2
, the first argument
is the temporary file with the modified parse tree and the second argument
the output file.
cmd2
also has a third argument (%3$s
) that contains a list of
extensions that are enabled or disabled. This is because some extensions
interfere with the conversion of the parsed tree to markdown. See
get_extensions
to see which extensions are disabled.
Value
Returns the file name of the file generated (ofn
). Called mainly for the
side effect of parsing and generating a markdown file (and possibly secondary
files such as figures).