-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Peculiar styling of messages in example output #79
Comments
Just sharing what I saw yesterday when the question was ask. pkgdown is setting a CSS for not of class message: https://github.com/r-lib/pkgdown/blob/dd94073575aaee2fd480892d24dfe0be85f81a03/inst/assets/pkgdown.css#L308 .message { color: black; font-weight: bolder;} This seem to lead to the bold text. About not everything is bold : downlit does not seem to produce valid HTML in this case: the closing See below,
> extract_output_part <- function(html) {
+ s <- stringr::str_locate(html, "<div class='output co'>")[, "start"]
+ stringr::str_sub(html, s)
+ }
>
> html1 <- downlit::evaluate_and_highlight('message("a")')
> extract_output_part(html1)
[1] "<div class='output co'>#> <span class='message'>a</span></div>"
>
> html2 <- downlit::evaluate_and_highlight('googlesheets4:::gs4_success("a")')
> extract_output_part(html2)
[1] "<div class='output co'>#> <span class='message'><span style='color: #00BB00;'>v</span><span> a</span></div></span>" I can't do a reprex above because this does not happens inside extract_output_part <- function(html) {
s <- stringr::str_locate(html, "<div class='output co'>")[, "start"]
stringr::str_sub(html, s)
}
html1 <- downlit::evaluate_and_highlight('message("a")')
extract_output_part(html1)
#> [1] "<div class='output co'>#> <span class='message'>a</span></div>"
html2 <- downlit::evaluate_and_highlight('googlesheets4:::gs4_success("a")')
extract_output_part(html2)
#> [1] "<div class='output co'>#> <span class='message'>v a</span></div>" Created on 2021-03-09 by the reprex package (v1.0.0.9002) Hope it helps. |
Somewhat more minimal reprex: library(downlit)
f <- function() cli::cli_alert_danger("x")
cat(evaluate_and_highlight("f()"))
#> <div class='input'><span class='fu'>f</span><span class='op'>(</span><span class='op'>)</span></div><div class='output co'>#> <span class='message'>x x</span></div> Created on 2021-04-27 by the reprex package (v2.0.0) |
Even simpler reprex: x <- "<div>\033[31mx\033[39m y</div>"
fansi::sgr_to_html(x)
#> [1] "<div><span style='color: #BB0000;'>x</span><span> y</div></span>" Created on 2021-04-27 by the reprex package (v2.0.0) |
@jennybc this makes the output consistent, but consistently bold. Removing the bold in r-lib/pkgdown#1644 . |
I can't figure out how downlit is deciding to show some messages in bold and not others.
I'm seeing this in the googlesheets4 examples. Here are few examples as of tidyverse/googlesheets4@9309c2a
Probably relevant: googlesheets4 is using cli (therefore
rlang::inform()
) for messages now.The basic pattern is: the first googlesheets4 message is bold, but no others.
Messages originating elsewhere, presumably coming via
message()
are ?always? bold. ("Files trashed..." is always coming from googledrive, for example).Below is a sampler.
https://googlesheets4.tidyverse.org/reference/range_read.html#examples
tidyverse/googlesheets4@9309c2a#diff-c089033b92eaa2e50242f2188feedb0d449c5fd93c1765301867ee1c9bb1ae39
https://googlesheets4.tidyverse.org/reference/range_speedread.html#examples
tidyverse/googlesheets4@9309c2a#diff-c755ed40978311fdb955d656db19f8477496e343ec19095b0cfcf64716ca26ec
https://googlesheets4.tidyverse.org/reference/sheet_write.html
tidyverse/googlesheets4@9309c2a#diff-19e7740a2d283dc1311c374e0bb4b937e9a904f3dbef7acb84432b9053abff3f
The text was updated successfully, but these errors were encountered: