Removes Magic Strings from a Word file
remove_magic_strings.Rd
Reads in a .docx file and returns a new version with magic strings removed from the document.
Examples
if (FALSE) { # \dontrun{
# ---------------------------------------------------------------------------
# Load all dependencies
# ---------------------------------------------------------------------------
docx_in <- file.path(here::here(), "report", "shell", "template.docx")
doc_dirs <- make_doc_dirs(docx_in = docx_in)
figures_path <- file.path(here::here(), "OUTPUTS", "figures")
tables_path <- file.path(here::here(), "OUTPUTS", "tables")
footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml")
# ---------------------------------------------------------------------------
# Step 1.
# Table addition running add_tables will format and insert tables into the doc.
# ---------------------------------------------------------------------------
add_tables(
docx_in = docx_in,
docx_out = doc_dirs$doc_tables,
tables_path = tables_path
)
# ---------------------------------------------------------------------------
# Step 2.
# Next we place in the plots using the add_plots function.
# ---------------------------------------------------------------------------
add_plots(
docx_in = doc_dirs$doc_tables,
docx_out = doc_dirs$doc_tabs_figs,
figures_path = figures_path
)
# ---------------------------------------------------------------------------
# Step 3.
# Now we can add the footnotes to all the inserted figures and tables.
# ---------------------------------------------------------------------------
add_footnotes(
docx_in = doc_dirs$doc_tabs_figs,
docx_out = doc_dirs$doc_draft,
figures_path = figures_path,
tables_path = tables_path,
footnotes = footnotes
)
# ---------------------------------------------------------------------------
# Step 4.
# Clean the output for a final document creation. This will remove the ties
# between reportifyr and the document so be careful!
# ---------------------------------------------------------------------------
remove_magic_strings(
docx_in = doc_dirs$doc_draft,
docx_out = doc_dirs$doc_final
)
} # }