Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions content/news/XXXX-XX-XX-render-math-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Now featuring MathJax
authors: Nikolaus Einhauser
status: draft
comments: yes
math: yes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is important, any article that wants to use math needs to opt into it (because I don't want to load it on every single article that doesn't need it)


Here's a pretty formula I like:

$$ \sum_{i=1}^{n}{i} = {n(n + 1) \over 2 }$$

also with inline $a_i$ variables
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
[[headers]]
for = "/news/*"
[headers.values]
# Additionally allow YouTube/Discourse frames and scripts
Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'sha256-UPkidoMErzWw1gW/eY4LhAi9ZkPch3PP31d6KQoJ6Yc=' 'sha256-G40wI6OaLZXCtrb02xUq1H1kEVWjstzoQ0FXKwsWxPw=' https://mixxx.discourse.group/javascripts/embed.js *.discourse-cdn.com; frame-src 'self' https://www.youtube-nocookie.com https://mixxx.discourse.group ; img-src 'self' https://i.ytimg.com ; connect-src 'self' https://mixxx.discourse.group https://*.discourse-cdn.com"
# Additionally allow YouTube/Discourse frames and scripts and MathJax
Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'sha256-UPkidoMErzWw1gW/eY4LhAi9ZkPch3PP31d6KQoJ6Yc=' 'sha256-G40wI6OaLZXCtrb02xUq1H1kEVWjstzoQ0FXKwsWxPw=' 'sha256-1CldwzdEg2k1wTmf7s5RWVd7NMXI/7nxxjJM2C4DqII=' https://mixxx.discourse.group/javascripts/embed.js *.discourse-cdn.com; frame-src 'self' https://www.youtube-nocookie.com https://mixxx.discourse.group ; img-src 'self' https://i.ytimg.com ; connect-src 'self' https://mixxx.discourse.group https://*.discourse-cdn.com"
7 changes: 7 additions & 0 deletions pelicanconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,15 @@
"download_metadata",
"draft_override",
"md_yaml",
"render_math",
]

MATH_JAX = {
# Disable auto_insert because we insert our own MathJax3 <script> into the needed articles.
# This also means that any settings created here are not relayed to mathjax (see templates/article.html instead)
"auto_insert": False,
}


class MenuItem:
def __init__(self, url, title, context, css="", children=()):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ markdown-full-yaml-metadata @ git+https://github.com/Holzhaus/python-markdown-fu
Markdown-Video @ git+https://github.com/Holzhaus/Python-Markdown-Video@98725ee09995fdeb05597d82defacaa7ceeca546
MarkupSafe==2.1.3
pelican==4.9.1
pelican-render-math==1.0.4
Pygments==2.17.2
python-dateutil==2.8.2
pytz==2023.3.post1
Expand Down
5 changes: 5 additions & 0 deletions theme/templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ <h4>{% trans %}Comments{% endtrans %}</h4>
{% if article.comments and article.comments in ("true", "yes") %}
<script src="{{ SITEURL }}/theme/js/discourse.js"></script>
{% endif %}
{% if article.math and article.math in ("true", "yes") %}
{# Note that we don't insert any mathjax config. If you want to configure mathjax, see https://docs.mathjax.org/en/latest/web/configuration.html#configuring-mathjax #}
{# pinning the latest MathJax and using Subresource integrity (since that allows us to avoid whitelisting all of jsdelivr in the CSP) #}
<script id="MathJax-script" type="text/javascript" integrity="sha256-1CldwzdEg2k1wTmf7s5RWVd7NMXI/7nxxjJM2C4DqII=" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
{% endif %}
{% endblock %}
Loading