Skip to content

Commit

Permalink
fix: captions management with bookdown
Browse files Browse the repository at this point in the history
see #645
  • Loading branch information
davidgohel committed Aug 3, 2024
1 parent 5a05c40 commit ae1ee65
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: flextable
Title: Functions for Tabular Reporting
Version: 0.9.7.002
Version: 0.9.7.003
Authors@R: c(
person("David", "Gohel", , "[email protected]", role = c("aut", "cre")),
person("ArData", role = "cph"),
Expand Down Expand Up @@ -57,7 +57,7 @@ Imports:
uuid (>= 0.1-4),
xml2
Suggests:
bookdown (>= 0.34),
bookdown (>= 0.40),
broom,
broom.mixed,
chromote,
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# flextable 0.9.7

## Issues

- fix caption issue that came with no version of bookdown (issue #645),
'bookdown' management of caption has been simplified.

# flextable 0.9.6

## Changes
Expand Down
3 changes: 0 additions & 3 deletions R/00_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,3 @@ with_openxml_unquote <- function(x) {
with_html_quotes <- function(x) {
paste("```{=html}", x, "```\n\n", sep = "\n")
}
with_html_unquotes <- function(...) {
paste("\n\n```\n", ..., "\n```{=html}\n\n", sep = "\n")
}
7 changes: 3 additions & 4 deletions R/captions.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ caption_bookdown_html <- function(x) {

reference_label <- ""
if (!is.null(x$caption$autonum$bookmark)) {
reference_label <- paste0("(\\#", x$caption$autonum$seq_id, ":", x$caption$autonum$bookmark, ")")
reference_label <- paste0("(#", x$caption$autonum$seq_id, ":", x$caption$autonum$bookmark, ")")
}

if (!is.null(x$caption$fp_p)) {
Expand All @@ -167,12 +167,11 @@ caption_bookdown_html <- function(x) {
caption_chunks_str <- html_caption$html
css <- html_caption$css
caption_str <- paste0(
sprintf("<caption%s%s>", inline_css, caption_class),
sprintf("\n<caption%s%s>", inline_css, caption_class),
reference_label,
caption_chunks_str,
"</caption>"
"</caption>\n"
)
caption_str <- with_html_unquotes(caption_str)

attr(caption_str, "css") <- css
caption_str
Expand Down

0 comments on commit ae1ee65

Please sign in to comment.