Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export(html_book)
export(html_chapters)
export(html_document2)
export(kindlegen)
export(odt_document2)
export(pdf_book)
export(pdf_document2)
export(powerpoint_presentation2)
export(preview_chapter)
export(publish_book)
export(render_book)
Expand Down
56 changes: 35 additions & 21 deletions R/word.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
#' @rdname html_document2
#' @export
word_document2 = function(fig_caption = TRUE, md_extensions = NULL, pandoc_args = NULL, ...) {
from = rmarkdown::from_rmarkdown(fig_caption, md_extensions)
office_document2_base = function(base_format) {
force(base_format)

config = rmarkdown::word_document(
fig_caption = fig_caption, md_extensions = md_extensions, pandoc_args = pandoc_args, ...
)
pre = config$pre_processor
config$pre_processor = function(metadata, input_file, ...) {
# Pandoc does not support numbered sections for Word, so figures/tables have
# to be numbered globally from 1 to n
process_markdown(input_file, from, pandoc_args, TRUE)
if (is.function(pre)) pre(metadata, input_file, ...)
}
post = config$post_processor
config$post_processor = function(metadata, input, output, clean, verbose) {
if (is.function(post)) output = post(metadata, input, output, clean, verbose)
move_output(output)
function(fig_caption = TRUE, md_extensions = NULL, pandoc_args = NULL, ...) {
from = rmarkdown::from_rmarkdown(fig_caption, md_extensions)

config = base_format(
fig_caption = fig_caption, md_extensions = md_extensions, pandoc_args = pandoc_args, ...
)
pre = config$pre_processor
config$pre_processor = function(metadata, input_file, ...) {
# Pandoc does not support numbered sections for Word, so figures/tables have
# to be numbered globally from 1 to n
process_markdown(input_file, from, pandoc_args, TRUE)
if (is.function(pre)) pre(metadata, input_file, ...)
}
post = config$post_processor
config$post_processor = function(metadata, input, output, clean, verbose) {
if (is.function(post)) output = post(metadata, input, output, clean, verbose)
move_output(output)
}
config$bookdown_output_format = config$pandoc$to
config = set_opts_knit(config)
config
}
config$bookdown_output_format = 'docx'
config = set_opts_knit(config)
config
}

#' @rdname html_document2
#' @export
word_document2 = office_document2_base(rmarkdown::word_document)

#' @rdname html_document2
#' @export
odt_document2 = office_document2_base(rmarkdown::odt_document)

#' @rdname html_document2
#' @export
powerpoint_presentation2 = office_document2_base(rmarkdown::powerpoint_presentation)
1 change: 1 addition & 0 deletions man/bookdown-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions man/html_document2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.