From 94abcfd542de7f7b429cb723f8b8f4a5d23cc935 Mon Sep 17 00:00:00 2001 From: Talon Poole Date: Sat, 20 Feb 2021 21:22:37 +0000 Subject: [PATCH] fix color-schemes --- README.md | 6 ++-- cli.js | 3 ++ css.js | 95 ++++++++++++++++++++++++++++++++++----------------- gmi-web.1.scd | 17 ++++----- html.js | 7 ++-- 5 files changed, 80 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 82f6cc6..ac577ec 100644 --- a/README.md +++ b/README.md @@ -162,15 +162,13 @@ gmi-web --config web.json $(find ~/gmi/dst -name '*.gmi') ## custom css -It is possible to use your own set of completely custom CSS rules by pointing to a .css file containing them. +It is possible to use your own set of completely custom CSS rules _and_ variables by pointing to a .css file containing them. ```sh gmi-web --body --css custom.css < doc.gmi ``` -gmi-web auto-detects the need for the `` color-schemes and allows for using `--inline` to insert the declarations as `style` properties on their respective blocks. - -[gmi.css](./gmi.css) is a good starting point! +gmi-web auto-detects the need for the `` color-schemes and allows for using `--inline` to insert the declarations as `style` properties on their respective blocks. Variables defined in `:root` will be picked up and made available for customization via command-line flags. # license diff --git a/cli.js b/cli.js index 22751a7..f6a6bcb 100755 --- a/cli.js +++ b/cli.js @@ -104,6 +104,9 @@ if (!argv.html && !argv.body) { cli.exit(1); } +argv.inlineCSS = CSS.inline(argv); +argv.styleTag = CSS.style(argv); + if (!argv.files) { let gemtext; try { diff --git a/css.js b/css.js index 6856864..2c747b7 100644 --- a/css.js +++ b/css.js @@ -6,10 +6,10 @@ import { stringify, parse } from "css"; export function style(options) { if (options.inline || options.css === "none") return ""; const rules = load(options); - const schemes = rules.find(({ media }) => media === "preferes-color-scheme") - ? `\n` + const schemes = rules.find(({ media }) => media) + ? `` : ""; - return `