Module: HunkReviewChanges::Assets
- Defined in:
- lib/hunk_review_changes/assets.rb
Overview
Generates the syntax-highlighting CSS shipped in app.css. Kept out of the request
path: rake css renders it once at build time so the running server only reads a
static file. Two themes are emitted under the same .highlight scope; the dark one
is wrapped in a prefers-color-scheme media query so the page follows the OS setting
with no toggle and no JavaScript.
Constant Summary collapse
- LIGHT_THEME =
"github"- DARK_THEME =
"github.dark"
Class Method Summary collapse
Class Method Details
.indent(text, spaces = 2) ⇒ Object
29 30 31 32 |
# File 'lib/hunk_review_changes/assets.rb', line 29 def indent(text, spaces = 2) pad = " " * spaces text.each_line.map { |line| line.strip.empty? ? line : "#{pad}#{line}" }.join end |
.rouge_css ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hunk_review_changes/assets.rb', line 17 def rouge_css light = Rouge::Theme.find(LIGHT_THEME).new(scope: ".highlight").render dark = Rouge::Theme.find(DARK_THEME).new(scope: ".highlight").render <<~CSS /* Syntax highlighting — generated by `rake css` from Rouge themes. */ #{light} @media (prefers-color-scheme: dark) { #{indent(dark)} } CSS end |