问题
I'm downloading a Google Doc as .docx and then converting to markdown for manipulation and export to multiple formats.
Problem: When I convert using pandoc, it strips title (and subtitle) and does not add any YAML header information. I could add title manually in the header, but I need it to be scripted, so need to not lose the title (ideally) or extract title from docx and add to YAML header, which would then be concatenated to the converted markdown file.
Example Code, where title is lost on conversion from docx to markdown:
require(rmarkdown);require(devtools)
examplefile=paste0(tempdir(),"/example.docx")
download.file("https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.docx",destfile=examplefile)
pandoc_convert(examplefile,to="markdown",output = "example.rmd", options=c("--extract-media=."))
render(paste0(tempdir(), "/example.rmd"),"html_document")
browseURL(paste0(tempdir(),"/example.html"))
来源:https://stackoverflow.com/questions/59652509/how-do-i-keep-title-subtitle-when-using-pandoc-to-convert-docx-to-md-in-r