diff --git a/R/utils_render_html.R b/R/utils_render_html.R index 5b5788c74d..2d24d5de59 100644 --- a/R/utils_render_html.R +++ b/R/utils_render_html.R @@ -3,9 +3,15 @@ #' @noRd footnote_mark_to_html <- function(mark) { - as.character( - htmltools::tagList(htmltools::tags$sup(class = "gt_footnote_marks", 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)) { + sup_class <- "gt_footnote_marks" + } else { + sup_class <- "gt_footnote_marks gt_asterisk" + } + + as.character(htmltools::tags$sup(class = sup_class, mark)) } styles_to_html <- function(styles) { @@ -1078,15 +1084,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") + ) ) ) } diff --git a/inst/css/gt_styles_default.scss b/inst/css/gt_styles_default.scss index 0924655463..31cbe171f6 100644 --- a/inst/css/gt_styles_default.scss +++ b/inst/css/gt_styles_default.scss @@ -354,7 +354,13 @@ .gt_footnote_marks { font-style: italic; font-weight: normal; - font-size: 65%; + font-size: 75%; + vertical-align: 0.4em; + } + + .gt_asterisk { + font-size: 100%; + vertical-align: 0; } .gt_slash_mark { 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
"