Skip to content

Commit

Permalink
improve compile report function (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-y authored Nov 5, 2024
1 parent 4e1c5af commit 14c27d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions R/compile_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ compile_report <- function(rmd_filename = list.files(pattern = "\\.Rmd$")[1],
)

officer::read_docx("temp_report.docx") %>%
officer::cursor_reach(keyword = "Introduction") %>%
officer::body_add_toc(pos = "before", level = toc_level) %>%
officer::cursor_begin() %>%
officer::body_add_par("Contents", pos = "before", style = "TOC Heading") %>%
officer::cursor_reach(keyword = "Introduction") %>%
officer::body_add_break(pos = "before") %>%
officer::body_add_toc(pos = "after", level = toc_level) %>%
officer::body_add_break(pos = "after") %>%
print("temp_report2.docx")

# Cover Page
Expand Down
7 changes: 3 additions & 4 deletions R/phs_report_docx.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ phs_report_docx <- function(toc = FALSE,
stitle = cover_subtitle, dt = cover_date,
tocd = toc_depth) {
officer::read_docx(output_file) %>%
officer::cursor_reach(keyword = "Introduction") %>%
officer::body_add_toc(pos = "before", level = tocd) %>%
officer::cursor_begin() %>%
officer::body_add_par("Contents", pos = "before", style = "TOC Heading") %>%
officer::cursor_reach(keyword = "Introduction") %>%
officer::body_add_break(pos = "before") %>%
officer::body_add_toc(pos = "after", level = tocd) %>%
officer::body_add_break(pos = "after") %>%
print(output_file)

# Cover Page
Expand Down

0 comments on commit 14c27d7

Please sign in to comment.