-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
caption
argument now supported for Markdown tables
- Loading branch information
1 parent
23383ee
commit eac88b5
Showing
6 changed files
with
62 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
finalize_bootstrap <- function(x) { | ||
if (meta(x)$output != "html") return(x) | ||
out <- gsub( | ||
"$tinytable_BOOTSTRAP_CLASS", | ||
"table", | ||
x, | ||
fixed = TRUE) | ||
# Rmarkdown and Quarto load their own bootstrap, which we probably don't want to override | ||
if (isTRUE(getOption('knitr.in.progress'))) { | ||
out <- strsplit(out, split = "\n")[[1]] | ||
out <- out[!grepl("https://cdn.jsdelivr.net/npm/bootstrap", out, fixed = TRUE)] | ||
out <- paste(out, collapse = "\n") | ||
} | ||
return(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
finalize_grid <- function(x) { | ||
if (meta(x)$output != "markdown") return(x) | ||
|
||
out <- x | ||
|
||
# formal grid specification in pandoc includes lines everywhere | ||
# important for docx output | ||
hlines <- getOption("tinytable_grid_hlines", default = TRUE) | ||
if (isTRUE(hlines)) { | ||
out <- grid_hlines(out) | ||
} | ||
|
||
cap <- meta(x, "caption") | ||
if (is.character(cap) && length(cap) == 1) { | ||
out <- paste0(out, "\n", "Table: ", cap, "\n") | ||
} | ||
|
||
return(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
|
||
+------+-----+------+ | ||
| mpg | cyl | disp | | ||
+======+=====+======+ | ||
| 21 | 6 | 160 | | ||
+------+-----+------+ | ||
| 21 | 6 | 160 | | ||
+------+-----+------+ | ||
| 22.8 | 4 | 108 | | ||
+------+-----+------+ | ||
|
||
Table: Blah blah blah | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters