From f044d25f7e5b682d56adf18b8bd7b9e8408c52cc Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 25 Oct 2019 12:12:57 +0100 Subject: [PATCH] Add output_classes property to external renderer, and new .invert-when-dark class in theme ABC Notation & Server-Side Latex look good naow! :D --- module_index.json | 2 +- modules/parser-parsedown.php | 4 ++- peppermint.guiconfig.json | 66 +++++++++++++++++++----------------- themes/default/theme.css | 2 ++ 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/module_index.json b/module_index.json index 907f820..ec8fd6b 100755 --- a/module_index.json +++ b/module_index.json @@ -337,7 +337,7 @@ "version": "0.10", "author": "Emanuil Rusev & Starbeamrainbowlabs", "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation.", - "lastupdate": 1571958901, + "lastupdate": 1572001815, "optional": false, "extra_data": { "Parsedown.php": "https:\/\/raw.githubusercontent.com\/erusev\/parsedown\/fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955\/Parsedown.php", diff --git a/modules/parser-parsedown.php b/modules/parser-parsedown.php index a76e678..1817ec4 100644 --- a/modules/parser-parsedown.php +++ b/modules/parser-parsedown.php @@ -1012,10 +1012,12 @@ class PeppermintParsedown extends ParsedownExtreme "name" => "img", "attributes" => [ "alt" => "Diagram rendered by {$renderer->name}", - "src" => "?action=parsedown-render-ext&language=$language&immutable_key=".hash("crc32b", json_encode($renderer))."&source=".rawurlencode($text) + "src" => "?action=parsedown-render-ext&language=".rawurlencode($language)."&immutable_key=".hash("crc32b", json_encode($renderer))."&source=".rawurlencode($text) ] ] ]; + if(!empty($renderer->output_classes)) + $result["element"]["element"]["attributes"]["class"] = implode(" ", $renderer->output_classes); return $result; } diff --git a/peppermint.guiconfig.json b/peppermint.guiconfig.json index d74a111..c7cb484 100644 --- a/peppermint.guiconfig.json +++ b/peppermint.guiconfig.json @@ -23,38 +23,40 @@ "parser_cache_min_size": { "type": "number", "description": "The minimum size a source string must be (in bytes) before it's considered eligible for caching.", "default": 1024 }, "parser_ext_renderers_enabled": { "type": "checkbox", "description": "Whether to enable external diagram renderer support, which is part of the parsedown parser. See the parser_ext_renderers setting below for more information.", "default": true }, "parser_ext_renderers": { "type": "parserext", "description": "Used by the parsedown parser as an object mapping fenced code block languages to their respective external renderers. Should be in the form language_codeexternal renderer definition. See the default for examples on how to define an external renderer. Warning: On Windows, the enforcement of strict time limits is not possible. Beware of DoS attacks!", "default": { - "nomnoml": { - "name": "nomnoml", - "description": "The nomnoml UML diagram renderer. Requires the 'nomnoml' npm package to be globally installed.", - "url": "http://nomnoml.com/", - "cli": "nomnoml {input_file} {output_file} 0", - "cli_mode": "file", - "output_format": "image/svg+xml" - }, - "plantuml": { - "name": "PlantUML", - "description": "The PlantUML diagram renderer. Supports many different diagram types. Requires plantuml to be installed.", - "url": "http://plantuml.com/", - "cli": "plantuml -tsvg -pipe", - "cli_mode": "pipe", - "output_format": "image/svg+xml" - }, - "abc": { - "name": "ABC Notation", - "description": "A simple music notation typesetter. Much easier to understand than Lilypond. Requires abcm2ps to be installed.", - "url": "https://abcnotation.com/", - "cli": "abcm2ps -g -O - -", - "cli_mode": "pipe", - "output_format": "image/svg+xml" - }, - "latexserver": { - "name": "Server-Side MathJax", - "description": "Client-side Mathjax via the 'enable_math_rendering' setting not your thing? Try it server-side instead! Requires the 'mathjax-node-cli' npm package to be globally installed.", - "url": "https://github.com/mathjax/mathjax-node-cli/blob/master/package.json#L41", - "cli": "tex2svg -- {input_text}", - "cli_mode": "substitution_pipe", - "output_format": "image/svg+xml" - } + "nomnoml": { + "name": "nomnoml", + "description": "The nomnoml UML diagram renderer. Requires the 'nomnoml' npm package to be globally installed.", + "url": "http:\/\/nomnoml.com\/", + "cli": "nomnoml {input_file} {output_file} 0", + "cli_mode": "file", + "output_format": "image\/svg+xml" + }, + "plantuml": { + "name": "PlantUML", + "description": "The PlantUML diagram renderer. Supports many different diagram types. Requires plantuml to be installed.", + "url": "http:\/\/plantuml.com\/", + "cli": "plantuml -tsvg -pipe", + "cli_mode": "pipe", + "output_format": "image\/svg+xml" + }, + "abc": { + "name": "ABC Notation", + "description": "A simple music notation typesetter. Much easier to understand than Lilypond. Requires abcm2ps to be installed.", + "url": "https:\/\/abcnotation.com\/", + "cli": "abcm2ps -g -O - -", + "cli_mode": "pipe", + "output_format": "image\/svg+xml", + "output_classes": [ "invert-when-dark" ] + }, + "latexserver": { + "name": "Server-Side MathJax", + "description": "Client-side Mathjax via the 'enable_math_rendering' setting not your thing? Try it server-side instead! Requires the 'mathjax-node-cli' npm package to be globally installed.", + "url": "https:\/\/github.com\/mathjax\/mathjax-node-cli\/blob\/master\/package.json#L41", + "cli": "tex2svg -- {input_text}", + "cli_mode": "substitution_pipe", + "output_format": "image\/svg+xml", + "output_classes": [ "invert-when-dark" ] + } } }, "parser_ext_time_limit": { "type": "number", "description": "The number of seconds external renderers are allowed to run for. Has no effect if external renderers are turned off. Also currently has no effect on Windows.", "default": 5 }, "parser_ext_allow_anon": { "type": "checkbox", "description": "

Whether to allow anonymous users to render new diagrams with the external renderer. When disabled, anonymous users will still be allowed to recall pre-rendered items from the cache, but will be unable to generate brand-new diagrams.

Note that if you allow anonymous edits this setting won't fully protect you: anonymous users could edit a page and insert a malicious diagram, and then laer a logged in user could unwittingly invoke the external renderer on the anonymous user's behalf.", "default": false }, diff --git a/themes/default/theme.css b/themes/default/theme.css index eca34d6..29f3e1b 100644 --- a/themes/default/theme.css +++ b/themes/default/theme.css @@ -95,6 +95,8 @@ a:hover { color: hsl(214, 67%, 75%); } a:active, a:focus { color: hsl(214, 87%, 85%); } a:visited { color: hsl(264, 77%, 65%); } + + .invert-when-dark { filter: invert(100%); } } /* TODO: Refactor to use the CSS grid */