From 629ef92b843696e08223a8a31c88470765513dff Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 4 Feb 2022 00:36:00 -0500 Subject: [PATCH 1/6] Improve positioning of footnote marks --- inst/css/gt_styles_default.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inst/css/gt_styles_default.scss b/inst/css/gt_styles_default.scss index 1da7f1d405..6f8fa52618 100644 --- a/inst/css/gt_styles_default.scss +++ b/inst/css/gt_styles_default.scss @@ -354,7 +354,8 @@ .gt_footnote_marks { font-style: italic; font-weight: normal; - font-size: 65%; + font-size: 75%; + vertical-align: 0.4em; } } From 6e89ada961726b0e2acb3f7500cbc387901c305b Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 4 Feb 2022 00:36:31 -0500 Subject: [PATCH 2/6] Apply superscript except for `*` --- R/utils_render_html.R | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/R/utils_render_html.R b/R/utils_render_html.R index 5b5788c74d..80100c12d2 100644 --- a/R/utils_render_html.R +++ b/R/utils_render_html.R @@ -3,9 +3,13 @@ #' @noRd footnote_mark_to_html <- function(mark) { - as.character( - htmltools::tagList(htmltools::tags$sup(class = "gt_footnote_marks", mark)) - ) + if (!grepl("^[\\*]+?$", mark)) { + as.character( + htmltools::tagList(htmltools::tags$sup(class = "gt_footnote_marks", mark)) + ) + } else { + mark + } } styles_to_html <- function(styles) { @@ -1078,15 +1082,14 @@ create_footnotes_component_h <- function(data) { FUN = function(x, footnote_text) { as.character( htmltools::tagList( - htmltools::tags$sup( - .noWS = c("after", "before"), - class = "gt_footnote_marks", - htmltools::tags$em( - .noWS = c("after", "before"), - paste0(x, " ") - ) - ), - htmltools::HTML(process_text(footnote_text, context = "html")) + htmltools::HTML( + paste0( + footnote_mark_to_html(x), + " ", + process_text(footnote_text, context = "html") + ), + .noWS = c("after", "before") + ) ) ) } From e1d943774cf8a0a237145548983757f5513b9c7a Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 4 Feb 2022 00:36:40 -0500 Subject: [PATCH 3/6] Update snapshot tests --- tests/testthat/_snaps/footer.md | 6 +++--- tests/testthat/_snaps/tab_options.md | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/testthat/_snaps/footer.md b/tests/testthat/_snaps/footer.md index 3139de3d61..6a15eae1ae 100644 --- a/tests/testthat/_snaps/footer.md +++ b/tests/testthat/_snaps/footer.md @@ -3,7 +3,7 @@ Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
num1char2fctrdatetimedatetimecurrencyrowgroup
0.1111apricotone2015-01-1513:352018-01-01 02:2249.95row_1grp_a
Source note **bold** (#1, no `md()`)
Source note bold (#2, uses md())
1 footnote **bold** (#1, no `md()`)
2 footnote bold (#2, uses md())
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
num1char2fctrdatetimedatetimecurrencyrowgroup
0.1111apricotone2015-01-1513:352018-01-01 02:2249.95row_1grp_a
Source note **bold** (#1, no `md()`)
Source note bold (#2, uses md())
1 footnote **bold** (#1, no `md()`)
2 footnote bold (#2, uses md())
" --- @@ -122,7 +122,7 @@ Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
num1char2fctrdatetimedatetimecurrencyrowgroup
0.1111apricotone2015-01-1513:352018-01-01 02:2249.95row_1grp_a
\n
Source note **bold** (#1, no `md()`)  Source note bold (#2, uses md())
\n
\n
1 footnote **bold** (#1, no `md()`)  2 footnote bold (#2, uses md())
\n
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
num1char2fctrdatetimedatetimecurrencyrowgroup
0.1111apricotone2015-01-1513:352018-01-01 02:2249.95row_1grp_a
\n
Source note **bold** (#1, no `md()`)  Source note bold (#2, uses md())
\n
\n
1 footnote **bold** (#1, no `md()`)  2 footnote bold (#2, uses md())
\n
" --- @@ -241,7 +241,7 @@ Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
num1char2fctrdatetimedatetimecurrencyrowgroup
0.1111apricotone2015-01-1513:352018-01-01 02:2249.95row_1grp_a
\n
Source note **bold** (#1, no `md()`) | Source note bold (#2, uses md())
\n
\n
1 footnote **bold** (#1, no `md()`) | 2 footnote bold (#2, uses md())
\n
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
num1char2fctrdatetimedatetimecurrencyrowgroup
0.1111apricotone2015-01-1513:352018-01-01 02:2249.95row_1grp_a
\n
Source note **bold** (#1, no `md()`) | Source note bold (#2, uses md())
\n
\n
1 footnote **bold** (#1, no `md()`) | 2 footnote bold (#2, uses md())
\n
" --- diff --git a/tests/testthat/_snaps/tab_options.md b/tests/testthat/_snaps/tab_options.md index 7d0c7629f2..f984eae51e 100644 --- a/tests/testthat/_snaps/tab_options.md +++ b/tests/testthat/_snaps/tab_options.md @@ -3,26 +3,26 @@ Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" --- Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" --- Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" --- Code . Output - [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" + [1] "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n
The mtcars Dataset1
What a great dataset this is
mpgcyl\n performance\n wtqsecvsamgearcarb
disphpdrat
Mazda RX421.061601103.902.62016.460144
Mazda RX4 Wag21.061601103.902.87517.020144
Datsun 71022.84108933.852.32018.611141
Hornet 4 Drive21.462581103.083.21519.441031
Hornet Sportabout18.783601753.153.44017.020032
Dataset is generally available in R
1 A table footnote
" From 21f573cc6bad1cedcc9312e7ea0b25c32e69f7ab Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 7 Feb 2022 16:34:44 -0500 Subject: [PATCH 4/6] Add `.gt_asterisk` class to default SCSS --- inst/css/gt_styles_default.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inst/css/gt_styles_default.scss b/inst/css/gt_styles_default.scss index 6f8fa52618..9a53429d08 100644 --- a/inst/css/gt_styles_default.scss +++ b/inst/css/gt_styles_default.scss @@ -358,4 +358,9 @@ vertical-align: 0.4em; } + .gt_asterisk { + font-size: 100%; + vertical-align: 0; + } + } From c6d78376a9616b8c6f4e3b13d45929adbfd4f0d2 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 7 Feb 2022 16:35:06 -0500 Subject: [PATCH 5/6] Apply `gt_asterisk` where necessary --- R/utils_render_html.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/utils_render_html.R b/R/utils_render_html.R index 80100c12d2..2ee9c7e50c 100644 --- a/R/utils_render_html.R +++ b/R/utils_render_html.R @@ -3,13 +3,15 @@ #' @noRd footnote_mark_to_html <- function(mark) { + # Generate the CSS classes needed on the basis of whether the + # mark is one or more asterisk characters or anything else if (!grepl("^[\\*]+?$", mark)) { - as.character( - htmltools::tagList(htmltools::tags$sup(class = "gt_footnote_marks", mark)) - ) + sup_class <- "gt_footnote_marks" } else { - mark + sup_class <- "gt_footnote_marks gt_asterisk" } + + as.character(htmltools::tagList(htmltools::tags$sup(class = sup_class, mark))) } styles_to_html <- function(styles) { From 165d334f655df9a91a6dc1222684d30176280ccd Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Tue, 8 Feb 2022 10:49:56 -0800 Subject: [PATCH 6/6] Remove unnecessary tagList --- R/utils_render_html.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils_render_html.R b/R/utils_render_html.R index 2ee9c7e50c..2d24d5de59 100644 --- a/R/utils_render_html.R +++ b/R/utils_render_html.R @@ -11,7 +11,7 @@ footnote_mark_to_html <- function(mark) { sup_class <- "gt_footnote_marks gt_asterisk" } - as.character(htmltools::tagList(htmltools::tags$sup(class = sup_class, mark))) + as.character(htmltools::tags$sup(class = sup_class, mark)) } styles_to_html <- function(styles) {