Skip to content

Commit e83bf44

Browse files
Swiftb0yjclsn
authored andcommitted
feat: add pelican-render-math plugin
1 parent fed1e39 commit e83bf44

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@
4848
[[headers]]
4949
for = "/news/*"
5050
[headers.values]
51-
# Additionally allow YouTube/Discourse frames and scripts
52-
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"
51+
# Additionally allow YouTube/Discourse frames and scripts and MathJax
52+
Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'sha256-UPkidoMErzWw1gW/eY4LhAi9ZkPch3PP31d6KQoJ6Yc=' 'sha256-G40wI6OaLZXCtrb02xUq1H1kEVWjstzoQ0FXKwsWxPw=' 'sha256-NoYDhgfdmQGg59XPik/7lIF57F0zlpWNHiB+uKc1Lc8=' https://mixxx.discourse.group/javascripts/embed.js *.discourse-cdn.com cdn.jsdelivr.net; 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"

pelicanconf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@
8989
"download_metadata",
9090
"draft_override",
9191
"md_yaml",
92+
"render_math",
9293
]
9394

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

95102
class MenuItem:
96103
def __init__(self, url, title, context, css="", children=()):

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ markdown-full-yaml-metadata @ git+https://github.com/Holzhaus/python-markdown-fu
99
Markdown-Video @ git+https://github.com/Holzhaus/Python-Markdown-Video@98725ee09995fdeb05597d82defacaa7ceeca546
1010
MarkupSafe==2.1.3
1111
pelican==4.9.1
12+
pelican-render-math==1.0.4
1213
Pygments==2.17.2
1314
python-dateutil==2.8.2
1415
pytz==2023.3.post1

theme/templates/article.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,9 @@ <h4>{% trans %}Comments{% endtrans %}</h4>
6868
{% block extra_head %}
6969
{% if article.comments and article.comments in ("true", "yes") %}
7070
<script src="{{ SITEURL }}/theme/js/discourse.js"></script>
71+
{% if article.math and article.math in ("true", "yes") %}
72+
{# mathjax version is pinned for security and version 2.7.9 because pelican-render-math likely doesn't support MathJax 3#}
73+
<script id="MathJax-script" type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
74+
{% endif %}
7175
{% endif %}
7276
{% endblock %}

0 commit comments

Comments
 (0)