noamross / redoc

[NOTE: Project in suspended animation for now] Reversible Reproducible Documents
https://noamross.github.io/redoc
Other
514 stars 44 forks source link

Import non-redoc docx files. #10

Open noamross opened 5 years ago

noamross commented 5 years ago

A convenience wrapper for converting non-redoc files will probably be useful. It can go beyond pandoc_convert() and do some things like setting up the YAML headers.

One possibility is that undoc() does this anyway with a warning/message.

statnmap commented 5 years ago

Thank you for your package. In case some person would like to import non-redoc docx files, they can cheat:

# In your R editor
# Create an empty Rmd
# add `output: redoc::redoc` in the YAML
# Save the Rmd : "my-document.Rmd"
# Render it in docx
rmarkdown::render("my-document.Rmd", output_format = redoc::redoc())

# Open the created docx with your doc editor
# Copy-paste the original.docx you wanted
# Close the editor

# > If you had images included
# Create a copy of your "original.docx"
# Change the extension as "original.zip"
# Unzip the file with your prefered unzipper
# Extract the "media" folder in the same directory as your "my-document.Rmd"

# Go back to your R editor and dedoc the file
redoc::dedoc(docx = "my-document.docx", overwrite = TRUE)
# redoc::dedoc_to_new_file(docx = "my-document.docx")

This is not perfect procedure, but it's a start.

statnmap commented 5 years ago

However, if you remove an image, because Word rename them image1.png, image2.png, ... Wrong images are used. I tried to rename them prior to render, but the name of my image is not accounted for when I dedoc.