Allow Latex equations in homepage banners and part comment.

This commit is contained in:
Jan Böhmer 2020-03-15 15:48:01 +01:00
parent 9dc5d325da
commit 562db6da06
5 changed files with 28 additions and 18 deletions

View file

@ -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 {

View file

@ -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 () {

View file

@ -1,3 +1,14 @@
Welcome to Part-DB.
<small>If you want to change this banner, edit `config/banner.md` file or set the `BANNER` environment variable.</small>
<blockquote class="pb-0">
<p style="font-size: 12px">
And God said <br>
$\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}$, <br>
and then there was light.
</p>
</blockquote>

View file

@ -101,7 +101,7 @@
<div class="tab-content" id="myTabContent">
{% if part.comment is not empty %}
<div class="tab-pane fade show" id="comment" role="tabpanel" aria-labelledby="home-tab">
<div class="container-fluid mt-2">
<div class="container-fluid mt-2 latex">
{{ part.comment|markdown }}
</div>
</div>

View file

@ -11,7 +11,7 @@
</h4>
{% if banner is not empty %}
<hr>
<div>
<div class="latex">
<h5>{{ banner | markdown }}</h5>
</div>
{% endif %}