knit_print_block: Force Block Printing while Knitting

Description Usage Arguments Value See Also Examples

View source: R/rdocx_knit_print.R

Description

When used in a loop, calls to blocks do not generate output because knit_print method is not called. Use the function to force printing. Also you should tell the chunk to use results 'as-is' (by adding results='asis' to your chunk header).

Usage

1

Arguments

x

a block object, result of a block function from officer package

...

unused arguments

Value

None. the function only print XML code.

See Also

Other functions that force printing: knit_print_run()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(rmarkdown)
rmd_file_src <- system.file(
  package = "officedown", "examples", "word_loop.Rmd")
rmd_file_des <- tempfile(fileext = ".Rmd")
if(pandoc_available()){

  file.copy(rmd_file_src, to = rmd_file_des)
  docx_file_1 <- tempfile(fileext = ".docx")
  render(rmd_file_des, output_file = docx_file_1, quiet = TRUE)

  if(file.exists(docx_file_1)){
    message("file ", docx_file_1, " has been written.")
  }
}

officedown documentation built on April 6, 2021, 1:06 a.m.