I recently made a comment about theme customisation in R Markdown in another thread:
This might be better broken off into a separate topic, but it seems like a lot of people are intimidated by slide theme customisation using CSS. I wonder if we could jam SASS into the xaringan build process and then have YAML parameters appended to or processed alongside the SASS.
It would mean that you could customise the theme directly from the YAML, and using SASS variables users would only need to make changes to a few variables set up by the theme author...
I'm splitting it off since it's not really on-topic where it is, but I'd like to see if anyone has had thoughts along these lines. If SASS could be run as part of the knitting process and given access to YAML options, it would be pretty easy for someone to write a theme in SASS and expose certain variables (like the font stack, colour palette or a general spacing variable). A package that did this could then provide an RMarkdown template where these variables are commented out to demonstrate to users how they can customise the theme. Something like:
---
title: "My awesome report"
date: "`r Sys.Date()`"
output:
xaringan::moon_reader:
css: ["sass-output.css"]
# uncomment these lines to customise the theme!
# sass:
# fonts: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif"
# colors:
# primary: "#ff00ff"
# secondary: red
# background: white
# spacing: 10px
---
I'm not sure if knitter can handle this sort of pre-processing (ie. pass YAML options off to another task), but I think worst case scenario you could just wrap the entire knitting function and trigger SASS before or after.
Does anyone have thoughts on this?