-
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.
- Loading branch information
Showing
14 changed files
with
184 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ Package: tinytable | |
Type: Package | ||
Title: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats | ||
Description: Create highly customized tables with this simple and dependency-free package. Data frames can be converted to 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', or 'Typst' tables. The user interface is minimalist and easy to learn. The syntax is concise. 'HTML' tables can be customized using the flexible 'Bootstrap' framework, and 'LaTeX' code with the 'tabularray' package. | ||
Version: 0.6.1.1 | ||
Version: 0.6.1.3 | ||
Imports: | ||
methods | ||
Depends: | ||
|
@@ -31,8 +31,8 @@ Suggests: | |
URL: https://vincentarelbundock.github.io/tinytable/ | ||
BugReports: https://github.com/vincentarelbundock/tinytable/issues | ||
Authors@R: c( | ||
person("Vincent", "Arel-Bundock", | ||
email = "[email protected]", | ||
person("Vincent", "Arel-Bundock", | ||
email = "[email protected]", | ||
role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-2042-7063"))) | ||
License: GPL (>= 3) | ||
|
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
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
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
Empty file.
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,121 @@ | ||
style_string_html <- function(n, styles) { | ||
if (isTRUE(styles[["italic"]])) { | ||
n <- sprintf("<i>%s</i>", n) | ||
} | ||
if (isTRUE(styles[["strikeout"]])) { | ||
n <- sprintf("<s>%s</s>", n) | ||
} | ||
if (isTRUE(styles[["underline"]])) { | ||
n <- sprintf("<u>%s</u>", n) | ||
} | ||
if (isTRUE(styles[["bold"]])) { | ||
n <- sprintf("<b>%s</b>", n) | ||
} | ||
if (isTRUE(styles[["monospace"]])) { | ||
n <- sprintf("<code>%s</code>", n) | ||
} | ||
if (!is.null(styles[["color"]])) { | ||
n <- sprintf("<span style='color:%s'>%s</span>", styles[["color"]], n) | ||
} | ||
if (!is.null(styles[["fontsize"]])) { | ||
n <- sprintf("<span style='font-size:%sem'>%s</span>", styles[["fontsize"]], n) | ||
} | ||
n | ||
} | ||
|
||
|
||
style_string_latex <- function(n, styles) { | ||
if (isTRUE(styles[["italic"]])) { | ||
n <- sprintf("\\textit{%s}", n) | ||
} | ||
if (isTRUE(styles[["strikeout"]])) { | ||
n <- sprintf("\\sout{%s}", n) | ||
} | ||
if (isTRUE(styles[["underline"]])) { | ||
n <- sprintf("\\underline{%s}", n) | ||
} | ||
if (isTRUE(styles[["bold"]])) { | ||
n <- sprintf("\\textbf{%s}", n) | ||
} | ||
if (isTRUE(styles[["monospace"]])) { | ||
n <- sprintf("\\texttt{%s}", n) | ||
} | ||
if (!is.null(styles[["color"]])) { | ||
n <- sprintf("\\textcolor{%s}{%s}", styles[["color"]], n) | ||
} | ||
if (!is.null(styles[["fontsize"]])) { | ||
n <- sprintf("{\\fontsize{%sem}{%sem}\\selectfont %s}", styles[["fontsize"]], styles[["fontsize"]], n) | ||
} | ||
n | ||
} | ||
|
||
|
||
style_string_typst <- function(n, styles) { | ||
sty <- NULL | ||
if (isTRUE(styles[["italic"]])) { | ||
sty <- c(sty, 'style: "italic"') | ||
} | ||
if (isTRUE(styles[["bold"]])) { | ||
sty <- c(sty, 'weight: "bold"') | ||
} | ||
if (isTRUE(styles[["strikeout"]])) { | ||
# not sure how to do this | ||
} | ||
if (isTRUE(styles[["underline"]])) { | ||
# not sure how to do this | ||
} | ||
if (!is.null(styles[["fontsize"]])) { | ||
fs <- sprintf("size: %sem", styles[["fontsize"]]) | ||
sty <- c(sty, fs) | ||
} | ||
if (!is.null(styles[["color"]])) { | ||
col <- styles[["color"]] | ||
if (grepl("^#", col)) col <- sprintf('rgb("%s")', col) | ||
col <- sprintf("fill: %s", col) | ||
sty <- c(sty, col) | ||
} | ||
template <- paste0("text(", paste(sty, collapse = ", "), ", [%s])") | ||
out <- sprintf(template, n) | ||
out <- sub("text(, ", "text(", out, fixed = TRUE) | ||
return(out) | ||
} | ||
|
||
|
||
|
||
style_notes <- function(x) { | ||
fun <- switch(x@output, | ||
"typst" = style_string_typst, | ||
"html" = style_string_html, | ||
"html_portable" = style_string_html, | ||
"latex" = style_string_latex, | ||
function(k, ...) identity(k) | ||
) | ||
x@notes <- lapply(x@notes, fun, x@style_notes) | ||
return(x) | ||
} | ||
|
||
style_notes <- function(x) { | ||
fun <- switch(x@output, | ||
"typst" = style_string_typst, | ||
"html" = style_string_html, | ||
"html_portable" = style_string_html, | ||
"latex" = style_string_latex, | ||
function(k, ...) identity(k) | ||
) | ||
x@notes <- lapply(x@notes, fun, x@style_notes) | ||
return(x) | ||
} | ||
|
||
style_caption <- function(x) { | ||
fun <- switch(x@output, | ||
"typst" = style_string_typst, | ||
"html" = style_string_html, | ||
"html_portable" = style_string_html, | ||
"latex" = style_string_latex, | ||
function(k, ...) identity(k) | ||
) | ||
if (length(x@caption) > 0) { | ||
x@caption <- fun(x@caption, x@style_caption) | ||
} | ||
return(x) | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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