From: Michael Tremer Date: Wed, 14 Jun 2023 08:50:36 +0000 (+0000) Subject: web: Text: Implement showing pre-formatted text X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bfbc002283d33b02e4177a8377ae82f070dd059;p=pbs.git web: Text: Implement showing pre-formatted text Signed-off-by: Michael Tremer --- diff --git a/src/templates/modules/text.html b/src/templates/modules/text.html index 774ccf3c..1be46353 100644 --- a/src/templates/modules/text.html +++ b/src/templates/modules/text.html @@ -1,3 +1,9 @@ -
- {% raw text %} -
+{% if text %} +
+ {% if pre %} +
{{ text }}
+ {% else %} + {% raw text %} + {% end %} +
+{% end %} diff --git a/src/web/ui_modules.py b/src/web/ui_modules.py index c1139d03..eb6626af 100644 --- a/src/web/ui_modules.py +++ b/src/web/ui_modules.py @@ -20,9 +20,13 @@ class TextModule(UIModule): """ Renders the text through the Markdown processor """ - def render(self, text): + def render(self, text, pre=False): + # Do nothing for no input + if text is None: + text = "" + # Pass the text through a markdown processor - if text: + if not pre and text: text = markdown.markdown(text, extensions=[ PrettyLinksExtension(), @@ -31,7 +35,7 @@ class TextModule(UIModule): "sane_lists", ]) - return self.render_string("modules/text.html", text=text) + return self.render_string("modules/text.html", text=text, pre=pre) class PrettyLinksExtension(markdown.extensions.Extension):