Skip to content

Commit c00e400

Browse files
committed
Fixes the anchors for footnotes in markdown, resolves sighingnow#109
Signed-off-by: Tao He <sighingnow@gmail.com>
1 parent d00c0ce commit c00e400

5 files changed

Lines changed: 150 additions & 2 deletions

File tree

_includes/body.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ <h1 id="{{ page.id }}">{{ site.title | escape }}</h1>
3838
{% if page.mermaid %}
3939
{% include mermaid.html %}
4040
{% endif %}
41+
42+
<!-- introduce mathjax support -->
43+
{% include fixes-chrome-anchors.html %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script>
2+
function fixes_chrome_anchors() {
3+
let chrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
4+
if (window.location.hash && chrome) {
5+
setTimeout(function () {
6+
var hash = window.location.hash;
7+
window.location.hash = "";
8+
window.location.hash = hash;
9+
}, 300);
10+
}
11+
}
12+
13+
if (document.readyState === "loading") {
14+
// Loading hasn't finished yet
15+
document.addEventListener("DOMContentLoaded", fixes_chrome_anchors);
16+
} else {
17+
// `DOMContentLoaded` has already fired
18+
fixes_chrome_anchors();
19+
}
20+
</script>

_posts/2023-12-12-footnotes.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: Using Footnotes
3+
author: Tao He
4+
date: 2023-12-12
5+
category: Jekyll
6+
layout: post
7+
mermaid: true
8+
---
9+
10+
This jekyll-theme supports [MathJax](https://www.mathjax.org/) to render footnotes
11+
in markdown.
12+
13+
e.g.,
14+
15+
```markdown
16+
The well known Pythagorean theorem $x^2 + y^2 = z^2$ was
17+
proved to be invalid for other exponents[^1].
18+
Meaning the next equation has no integer solutions:
19+
20+
$$ x^n + y^n = z^n $$
21+
```
22+
23+
The well known Pythagorean theorem $x^2 + y^2 = z^2$ was
24+
proved to be invalid for other exponents[^1].
25+
Meaning the next equation has no integer solutions:
26+
27+
$$ x^n + y^n = z^n $$
28+
29+
Long contents
30+
-------------
31+
32+
long contents .....
33+
34+
1. a
35+
2. b
36+
3. c
37+
4. d
38+
39+
### Sub title 1
40+
41+
### Sub title 2
42+
43+
### Sub title 3
44+
45+
Long contents
46+
-------------
47+
48+
long contents .....
49+
50+
1. a
51+
2. b
52+
3. c
53+
4. d
54+
55+
### Sub title 1
56+
57+
### Sub title 2
58+
59+
### Sub title 3
60+
61+
Long contents
62+
-------------
63+
64+
long contents .....
65+
66+
1. a
67+
2. b
68+
3. c
69+
4. d
70+
71+
### Sub title 1
72+
73+
### Sub title 2
74+
75+
### Sub title 3
76+
77+
Long contents
78+
-------------
79+
80+
long contents .....
81+
82+
1. a
83+
2. b
84+
3. c
85+
4. d
86+
87+
### Sub title 1
88+
89+
### Sub title 2
90+
91+
### Sub title 3
92+
93+
Long contents
94+
-------------
95+
96+
long contents .....
97+
98+
1. a
99+
2. b
100+
3. c
101+
4. d
102+
103+
### Sub title 1
104+
105+
### Sub title 2
106+
107+
### Sub title 3
108+
109+
Long contents
110+
-------------
111+
112+
long contents .....
113+
114+
1. a
115+
2. b
116+
3. c
117+
4. d
118+
119+
### Sub title 1
120+
121+
### Sub title 2
122+
123+
### Sub title 3
124+
125+
[^1]: [https://en.wikipedia.org/wiki/Fermat%27s_Last_Theorem](https://en.wikipedia.org/wiki/Fermat%27s_Last_Theorem)

assets/gitbook/gitbook.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/gitbook/theme.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)