]> git.ipfire.org Git - pbs.git/commitdiff
web: Text: Implement showing pre-formatted text
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 14 Jun 2023 08:50:36 +0000 (08:50 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 14 Jun 2023 08:50:36 +0000 (08:50 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/modules/text.html
src/web/ui_modules.py

index 774ccf3ce4623808c5626fa54b48941bbd56b518..1be4635383162e72ebaed171de3610f6ab296c73 100644 (file)
@@ -1,3 +1,9 @@
-<div class="content">
-       {% raw text %}
-</div>
+{% if text %}
+       <div class="content">
+               {% if pre %}
+                       <pre>{{ text }}</pre>
+               {% else %}
+                       {% raw text %}
+               {% end %}
+       </div>
+{% end %}
index c1139d03b22e7509726055c31b2f3cfb45d0d646..eb6626af839ed1e287f012ac57db288f1bc6742d 100644 (file)
@@ -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):