Convert a docx-file (a protocol) to an (R)markdown file
Source:R/convert_docx.R
convert_docx_to_rmd.RdThis function is derived from the
redoc::dedoc()
function and uses pandoc to convert between docx and markdown.
Several options are preset to end-up with a markdown document that is in
syntax as close as possible to Rmarkdown files in RStudio.
During conversion, graphics (e.g. png, jpg) will be extracted from the docx
archive and placed in a folder ./media and named image1, image2,
etcetera.
Additionally, .emf files will be converted to .png.
Arguments
- from
The
.docxfile to convert. Can be given as an absolute or relative path.- to
The filename including path to write the resulting
.Rmdfile. The default is to use the same name and path as the.docxdocument.- dir_media
The directory to write the folder
mediawith images to, relative to the folder where the.Rmdis written. Defaults to '.' (the path where the.Rmdfile is written).- wrap
The width at which to wrap text. If
NA(default), text is not wrapped.- overwrite
Whether or not to overwrite the
tofile if it already existed. Defaults toFALSE.- verbose
Whether to print
pandocprogress text. Defaults toFALSE.- wd
Current working directory (used to handle relative paths).
Details
Metadata in the page headers and footers of the docx are ignored and will thus be lost during conversion. In case the header or footer did contain important metadata, it will need to be recovered manually. Usually header information will go inside a yaml section of an Rmarkdown.
See also
Other convert:
add_captions()