themebuilding: Syntax highlighting theme building tools

colors_solarized_lightR Documentation

Syntax highlighting theme building tools

Description

Syntax highlighting theme building tools

Usage

colors_solarized_light()

copy_base_pandoc_theme(path)

set_theme_text_style(data, name, ...)

patch_theme_text_style(data, data_patches)

write_pandoc_theme(data, output_path)

Arguments

path

Path where to save pandoc's built-in syntax highlighting theme.

data

List containing data from a syntax highlighting theme's JSON file.

name

String name of the text styles to modify (e.g., "Function"). The theme is a list with global style settings and a sub-list text-styles with each of the specific token styles. (See examples.) Use "global" to modify the top-level theme elements or a name in data[["text-styles"]] to modify those styles.

...

Key-value pairs setting the style appearance. The keys can be one of the color setters: text (text-color), background (background-color), line (line-number-color), line_background (line-number-background-color). These fields take a hex color value. The keys can also be one of the font style setters: bold, underline, italic. These fields take TRUE or FALSE.

data_patches

Alternatively, we can provide provide a list of patches and use those to call set_theme_text_style(). For example, list(global = list(text = "#657b83"), Comment = list(color = "#93a1a1")) would apply the approach changes to the global and comment styles.

output_path

Path where to write out a pandoc syntax highlighting theme JSON file.

Value

copy_base_pandoc_theme(path) saves the pandoc syntax highlighting theme's JSON data to path and returns the path invisibly. set_theme_text_style() and patch_theme_text_style() return a modified syntax highlighting theme. write_pandoc_theme() writes out the pandoc syntax highlighting theme to a JSON file and invisibly returns the original data. colors_solarized_light() returns a list with the solarized light colors.

References

Solarized Light Theme colors via https://github.com/altercation/solarized#the-values

Examples

## Not run: 
s <- tempfile()
copy_base_pandoc_theme(s)
data_theme <- jsonlite::read_json(s)
str(data_theme, max.level = 2)
str(data_theme$`text-styles`$Comment)

# Interactive (pipe-able) interface

# bold pink roman comments
my_theme <- set_theme_text_style(
    data_theme,
    "Comment",
    text = "#ff748c",
    bold = TRUE,
    italic = FALSE
)
str(my_theme$`text-styles`$Comment)

# Patching interface

# Stub for a Fairy Floss theme https://github.com/sailorhg/fairyfloss
data_theme_patches <- list(
  global = list(text = "#F8F8F2", background = "#5A5475"),
  Function = list(text = "#C2FFDF"),
  Operator = list(text = "#FFB8D1"),
  Float = list(text = "#C5A3FF")
)
my_theme2 <- patch_theme_text_style(data_theme, data_theme_patches)
str(my_theme2$`text-styles`$Function)
str(my_theme2$`text-styles`$Float)

## End(Not run)

tjmahr/solarizeddocx documentation built on May 4, 2022, 3:35 p.m.