Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ export(html_book)
export(html_chapters)
export(html_document2)
export(kindlegen)
export(markdown_document2)
export(odt_document2)
export(pdf_book)
export(pdf_document2)
export(powerpoint_presentation2)
export(preview_chapter)
export(publish_book)
export(render_book)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGES IN bookdown VERSION 0.13

## NEW FEATURES

- Added `odt_document2` and `powerpoint_presentation2` (thanks, @atusy, #742).

- Added `markdown_document2` which enables to use cross references in an arbitrary format specified in `base_format` argument (e.g., `markdown_document2(base_format = prettydoc::html_pretty)`) (thanks, @atusy, #742).

# CHANGES IN bookdown VERSION 0.12

Expand Down
4 changes: 3 additions & 1 deletion R/html.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ tufte_html_book = function(...) {
#' \code{rmarkdown::\link{html_document}()}, and they added the capability of
#' numbering figures/tables/equations/theorems and cross-referencing them. See
#' References for the syntax. Note you can also cross-reference sections by
#' their ID's using the same syntax when sections are numbered.
#' their ID's using the same syntax when sections are numbered. In case you want
#' to enable cross reference in other formats, use \code{markdown_document2} with
#' \code{base_format} argument.
#' @param ...,fig_caption,md_extensions,pandoc_args Arguments to be passed to a
#' specific output format function. For a function \code{foo2()}, its
#' arguments are passed to \code{foo()}, e.g. \code{...} of
Expand Down
27 changes: 24 additions & 3 deletions R/word.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#' @rdname html_document2
#' @export
word_document2 = function(fig_caption = TRUE, md_extensions = NULL, pandoc_args = NULL, ...) {
markdown_document2 = function(
fig_caption = TRUE, md_extensions = NULL, pandoc_args = NULL, ..., base_format
) {
from = rmarkdown::from_rmarkdown(fig_caption, md_extensions)

config = rmarkdown::word_document(
base_format = get_base_format(base_format)
config = base_format(
fig_caption = fig_caption, md_extensions = md_extensions, pandoc_args = pandoc_args, ...
)
pre = config$pre_processor
Expand All @@ -18,7 +21,25 @@ word_document2 = function(fig_caption = TRUE, md_extensions = NULL, pandoc_args
if (is.function(post)) output = post(metadata, input, output, clean, verbose)
move_output(output)
}
config$bookdown_output_format = 'docx'
config$bookdown_output_format = config$pandoc$to
config = set_opts_knit(config)
config
}

#' @rdname html_document2
#' @export
word_document2 = function(...) {
markdown_document2(..., base_format = rmarkdown::word_document)
}

#' @rdname html_document2
#' @export
odt_document2 = function(...) {
markdown_document2(..., base_format = rmarkdown::odt_document)
}

#' @rdname html_document2
#' @export
powerpoint_presentation2 = function(...) {
markdown_document2(..., base_format = 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.

21 changes: 16 additions & 5 deletions man/html_document2.Rd

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