Title: | A 'Solarized' Theme for 'RMarkdown` `Docx` Documents |
---|---|
Description: | An 'RMarkdown' output format for 'Microsoft' Word '.docx' documents created by 'pandoc'. |
Authors: | Tristan Mahr [aut, cre] , Ethan Schoonover [ctb, cph] (Solarized color themes), John MacFarlane [ctb, cph] (Pandoc templates), KDE contributors [ctb] (R syntax definition https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/r.xml) |
Maintainer: | Tristan Mahr <[email protected]> |
License: | GPL (>= 3) + file LICENSE |
Version: | 0.0.1.9000 |
Built: | 2024-11-11 02:42:52 UTC |
Source: | https://github.com/tjmahr/solarizeddocx |
Syntax highlighting theme building tools
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)
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)
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., |
... |
Key-value pairs setting the style appearance. The keys can be one
of the color setters: |
data_patches |
Alternatively, we can provide provide a list of patches
and use those to call |
output_path |
Path where to write out a pandoc syntax highlighting theme JSON file. |
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.
Solarized Light Theme colors via https://github.com/altercation/solarized#the-values
## 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)
## 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)
Render and open the demo RMarkdown file
demo_document()
demo_document()
This function renders the built-in RMarkdown file and opens it. It returns the path to the rendered file invisibly.
Solarized Syntax Highlighting in Microsoft Word
document( ..., reference_docx = "solarized", highlight = "solarized", syntax_definition = "solarized", pandoc_args = character(0) )
document( ..., reference_docx = "solarized", highlight = "solarized", syntax_definition = "solarized", pandoc_args = character(0) )
... |
Arguments passed to |
reference_docx |
Reference docx file to use. By default, this value is
set to use |
highlight |
Syntax highlighting style to use. By default, this value is
set to |
syntax_definition |
Syntax definition to use for syntax highlighting.
Defaults to |
pandoc_args |
Additional command line options to pass to pandoc. (This should be a character vector of options.) |
An RMarkdown output format for Word documents.
## Not run: rmarkdown::render("test.Rmd", output_format = solarizeddocx::document()) ## End(Not run)
## Not run: rmarkdown::render("test.Rmd", output_format = solarizeddocx::document()) ## End(Not run)
Retrieve file paths to package resources
file_reference_docx() file_syntax_definition() file_solarized_light_theme() file_syntax_test() file_code_block()
file_reference_docx() file_syntax_definition() file_solarized_light_theme() file_syntax_test() file_code_block()
file_reference_docx()
returns the path to the reference docx file
used by this package. file_syntax_definition()
returns the path to the
XML file specifying how pandoc should highlight the code in the document.
file_solarized_light_theme()
returns the path to the .theme file used by
this package. file_syntax_test()
returns the path to the RMarkdown file
used by demo_document()
. file_code_block()
returns a minimal .Rmd file
with a single code block for small illustrations.
the reference docx is a modified version of the own built into pandoc by John MacFarlane. The syntax definition is a modified version of the one by the KDE developers. I used the code here: https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/r.xml