From 562db6da060d7b758d9faf97dca93b1d9fcb02a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 15 Mar 2020 15:48:01 +0100 Subject: [PATCH] Allow Latex equations in homepage banners and part comment. --- assets/css/app.css | 2 +- assets/ts_src/event_listeners.ts | 27 +++++++++---------- config/banner.md | 13 ++++++++- templates/Parts/info/show_part_info.html.twig | 2 +- templates/homepage.html.twig | 2 +- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index 7d624435..296d0bd5 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -811,7 +811,7 @@ div.dataTables_wrapper div.dataTables_info { padding: 10px 10px; margin: 0 0 10px; font-size: 17.5px; - border-left: 5px solid #eee; + border-left: 5px solid #aaa; } .darkmode-layer { diff --git a/assets/ts_src/event_listeners.ts b/assets/ts_src/event_listeners.ts index 50280bec..99a0a032 100644 --- a/assets/ts_src/event_listeners.ts +++ b/assets/ts_src/event_listeners.ts @@ -465,6 +465,19 @@ $(document).on("ajaxUI:start", function () { //Bootstrapify objects $('table', this).addClass('table table-hover table-striped table-bordered'); }); + + //Latex rendering have to be done after markdown parsing + $('.latex').each(function(index, element) { + //@ts-ignore + window.renderMathInElement(element, { + delimiters: [ + {left: "$$", right: "$$", display: true}, + {left: "$", right: "$", display: false}, + {left: "\\(", right: "\\)", display: false}, + {left: "\\[", right: "\\]", display: true} + ] + }); + }); } //Configure markdown @@ -552,20 +565,6 @@ $(document).on("ajaxUI:reload", function() { }) }); -//Register latex rendering -$(document).on("ajaxUI:reload ajaxUI:start", function() { - $('.latex').each(function(index, element) { - //@ts-ignore - window.renderMathInElement(element, { - delimiters: [ - {left: "$$", right: "$$", display: true}, - {left: "$", right: "$", display: false}, - {left: "\\(", right: "\\)", display: false}, - {left: "\\[", right: "\\]", display: true} - ] - }); - }); -}); //Need for proper body padding, with every navbar height $(window).resize(function () { diff --git a/config/banner.md b/config/banner.md index 74b1d526..997ca15e 100644 --- a/config/banner.md +++ b/config/banner.md @@ -1,3 +1,14 @@ Welcome to Part-DB. -If you want to change this banner, edit `config/banner.md` file or set the `BANNER` environment variable. \ No newline at end of file +If you want to change this banner, edit `config/banner.md` file or set the `BANNER` environment variable. + +
+

+And God said
+$\nabla \cdot \vec{D} = \rho$, +$\nabla \cdot \vec{B} = 0$, +$\nabla \times \vec{E} = -\frac{\partial \vec{B}}{\partial t}$, +$\nabla \times \vec{H} = \vec{j} + \frac{\partial \vec{D}}{\partial t}$,
+and then there was light. +

+
\ No newline at end of file diff --git a/templates/Parts/info/show_part_info.html.twig b/templates/Parts/info/show_part_info.html.twig index 771a941e..a8fe469a 100644 --- a/templates/Parts/info/show_part_info.html.twig +++ b/templates/Parts/info/show_part_info.html.twig @@ -101,7 +101,7 @@
{% if part.comment is not empty %}
-
+
{{ part.comment|markdown }}
diff --git a/templates/homepage.html.twig b/templates/homepage.html.twig index ba029fc1..37bc2068 100644 --- a/templates/homepage.html.twig +++ b/templates/homepage.html.twig @@ -11,7 +11,7 @@ {% if banner is not empty %}
-
+
{{ banner | markdown }}
{% endif %}