Skip to content

Instantly share code, notes, and snippets.

@romainfrancois
Created October 5, 2017 09:27
Show Gist options
  • Save romainfrancois/c1c8b6d474c04d07104f543bb3c4ca5b to your computer and use it in GitHub Desktop.
Save romainfrancois/c1c8b6d474c04d07104f543bb3c4ca5b to your computer and use it in GitHub Desktop.
library(css)
library(glue)
library(rvest)
library(stringr)
library(dplyr)
library(purrr)
directory <- "https://github.com/rstudio/rstudio/blob/master/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/themes"
raw_directory <- "https://raw.githubusercontent.com/rstudio/rstudio/master/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/themes"
rstudio_theme_names <- read_html(directory) %>%
html_nodes("a[title$='css']") %>%
html_text() %>%
str_replace( "[.]css$", "")
rstudio_themes <- map_df( rstudio_theme_names, ~{
theme <- .
read_css(glue("{raw_directory}/{theme}.css")) %>%
mutate( theme = theme )
})
darkness <- rstudio_themes %>%
filter( str_detect(rule, "ace_editor_theme"), property == "background-color" ) %>%
mutate(dark = colMeans(col2rgb(value)) < 128 ) %>%
select( theme, dark )
rstudio_themes <- left_join(rstudio_themes, darkness, by = "theme")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment