Skip to content

Commit e6542e3

Browse files
authored
fix tikzjax (#3477)
Fixes #3216 – TikZJax not working. 1. Changing SHA simply doesn't work, `window.tikzjax` is undefined and it doesn't render anything. 2. I switched to the JS distributed by [benrbray/tikzjax](https://github.com/benrbray/tikzjax/tree/develop), added under `assets.js` to prevent future issues. 3. Documents now require to start with `\begin{document}`, should be a simple fix. <img width="789" height="341" alt="Screenshot 2026-01-24 at 1 10 39 PM" src="https://github.com/user-attachments/assets/8272471d-df94-4118-a726-00ed09dcf1e8" /> <img width="780" height="380" alt="Screenshot 2026-01-24 at 1 06 13 PM" src="https://github.com/user-attachments/assets/11284661-de15-4d57-a1d9-4959f562f826" />
1 parent 1cc23ba commit e6542e3

File tree

7 files changed

+5163
-54
lines changed

7 files changed

+5163
-54
lines changed

_includes/distill_scripts.liquid

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,7 @@
120120

121121
{% if page.tikzjax %}
122122
<!-- Tikzjax -->
123-
<script
124-
defer
125-
src="https://tikzjax.com/v1/tikzjax.js"
126-
integrity="sha256-+1qyucCXRZJrCg3lm3KxRt/7WXaYhBid4/1XJRHGB1E="
127-
crossorigin="anonymous"
128-
></script>
123+
<script defer src="{{ '/assets/js/tikzjax.min.js' | relative_url | bust_file_cache }}" type="text/javascript"></script>
129124
{% endif %}
130125

131126
{% if page.typograms %}

_includes/head.liquid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@
193193
{% endif %}
194194

195195
{% if page.tikzjax %}
196-
<link defer rel="stylesheet" type="text/css" href="https://tikzjax.com/v1/fonts.css">
196+
<link defer rel="stylesheet" type="text/css" href="{{ '/assets/css/tikzjax.min.css' | relative_url | bust_file_cache }}">
197197
{% endif %}

_includes/scripts.liquid

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@
139139

140140
{% if page.tikzjax %}
141141
<!-- Tikzjax -->
142-
<script
143-
defer
144-
src="https://tikzjax.com/v1/tikzjax.js"
145-
integrity="sha256-+1qyucCXRZJrCg3lm3KxRt/7WXaYhBid4/1XJRHGB1E="
146-
crossorigin="anonymous"
147-
></script>
142+
<script defer src="{{ '/assets/js/tikzjax.min.js' | relative_url | bust_file_cache }}" type="text/javascript"></script>
148143
{% endif %}
149144

150145
{% if page.typograms %}

_posts/2018-12-22-distill.md

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,48 +1210,52 @@ The rendered output shows a clean and simple bar chart with a hover effect:
12101210

12111211
```markdown
12121212
<script type="text/tikz">
1213-
\begin{tikzpicture}
1214-
\filldraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);
1215-
1216-
\draw[->, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
1217-
\draw[->, thick] (0,-2.5) -- (0,2.5) node[above] {Im};
1218-
1219-
\draw[->, thick, color=purple] (0,0) -- (1.5,1.5);
1220-
\node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};
1221-
1222-
\draw[thick] (0.7,0) arc (0:45:0.7);
1223-
\node at (0.9, 0.3) {$\theta$};
1224-
1225-
\draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
1226-
\draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
1227-
\node at (2.2, 0) [below] {1};
1228-
\node at (0, 2.2) [left] {$i$};
1229-
\node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
1230-
\end{tikzpicture}
1213+
\begin{document}
1214+
\begin{tikzpicture}
1215+
\filldraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);
1216+
1217+
\draw[->, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
1218+
\draw[->, thick] (0,-2.5) -- (0,2.5) node[above] {Im};
1219+
1220+
\draw[->, thick, color=purple] (0,0) -- (1.5,1.5);
1221+
\node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};
1222+
1223+
\draw[thick] (0.7,0) arc (0:45:0.7);
1224+
\node at (0.9, 0.3) {$\theta$};
1225+
1226+
\draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
1227+
\draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
1228+
\node at (2.2, 0) [below] {1};
1229+
\node at (0, 2.2) [left] {$i$};
1230+
\node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
1231+
\end{tikzpicture}
1232+
\end{document}
12311233
</script>
12321234
```
12331235

12341236
The rendered output is shown below, displayed as a vector graphic:
12351237

12361238
<script type="text/tikz">
1237-
\begin{tikzpicture}
1238-
\filldraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);
1239-
1240-
\draw[->, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
1241-
\draw[->, thick] (0,-2.5) -- (0,2.5) node[above] {Im};
1242-
1243-
\draw[->, thick, color=purple] (0,0) -- (1.5,1.5);
1244-
\node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};
1245-
1246-
\draw[thick] (0.7,0) arc (0:45:0.7);
1247-
\node at (0.9, 0.3) {$\theta$};
1248-
1249-
\draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
1250-
\draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
1251-
\node at (2.2, 0) [below] {1};
1252-
\node at (0, 2.2) [left] {$i$};
1253-
\node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
1254-
\end{tikzpicture}
1239+
\begin{document}
1240+
\begin{tikzpicture}
1241+
\filldraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);
1242+
1243+
\draw[->, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
1244+
\draw[->, thick] (0,-2.5) -- (0,2.5) node[above] {Im};
1245+
1246+
\draw[->, thick, color=purple] (0,0) -- (1.5,1.5);
1247+
\node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};
1248+
1249+
\draw[thick] (0.7,0) arc (0:45:0.7);
1250+
\node at (0.9, 0.3) {$\theta$};
1251+
1252+
\draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
1253+
\draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
1254+
\node at (2.2, 0) [below] {1};
1255+
\node at (0, 2.2) [left] {$i$};
1256+
\node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
1257+
\end{tikzpicture}
1258+
\end{document}
12551259
</script>
12561260

12571261
---

_posts/2023-12-12-tikzjax.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ tikzjax: true
1111
This is an example post with TikZ code. TikZJax converts script tags (containing TikZ code) into SVGs.
1212

1313
<script type="text/tikz">
14-
\begin{tikzpicture}
15-
\draw[red,fill=black!60!red] (0,0) circle [radius=1.5];
16-
\draw[green,fill=black!60!green] (0,0) circle [x radius=1.5cm, y radius=10mm];
17-
\draw[blue,fill=black!60!blue] (0,0) circle [x radius=1cm, y radius=5mm, rotate=30];
18-
\end{tikzpicture}
14+
\begin{document}
15+
\begin{tikzpicture}
16+
\draw[red,fill=black!60!red] (0,0) circle [radius=1.5];
17+
\draw[green,fill=black!60!green] (0,0) circle [x radius=1.5cm, y radius=10mm];
18+
\draw[blue,fill=black!60!blue] (0,0) circle [x radius=1cm, y radius=5mm, rotate=30];
19+
\end{tikzpicture}
20+
\end{document}
1921
</script>

assets/css/tikzjax.min.css

Lines changed: 700 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/tikzjax.min.js

Lines changed: 4413 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)