-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreamble.html
More file actions
155 lines (133 loc) · 5.29 KB
/
Copy pathpreamble.html
File metadata and controls
155 lines (133 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html>
<head>
<title> HEADER </title>
<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
<script src= "https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script>
window.MathJax = {
tex: {
tags: 'ams',
inlineMath: [['$', '$'], ['\\(', '\\)']], // enable $...$ for inline
displayMath: [['$$', '$$'], ['\\[', '\\]']], // block math
macros: {
Rb: "\\mathbb{R}",
gf: "\\mathfrak{g}",
su: "\\mathfrak{su}",
sl: "\\mathfrak{sl}(2, \\mathbb{C})",
Ac: "\\mathcal{A}"
}
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
};
document.addEventListener("DOMContentLoaded", async () => {
const refSection = document.getElementById("reference-section");
const refList = document.getElementById("references");
let bib = null;
// -------------------------
// 1. Try loading bibliography.json
// -------------------------
try {
const response = await fetch("bibliography.json");
if (!response.ok) throw new Error("File not found");
bib = await response.json();
} catch (err) {
// If file missing → hide section entirely
refSection.style.display = "none";
return;
}
// -------------------------
// 2. Process citations
// -------------------------
let counter = 1;
const refNumbers = {};
let citationCount = 0;
document.querySelectorAll("cite").forEach(c => {
const key = c.getAttribute("key");
// If this key not in bibliography → skip it quietly
if (!bib || !(key in bib)) {
c.innerHTML = "[?]";
return;
}
citationCount++;
if (!(key in refNumbers)) refNumbers[key] = counter++;
c.innerHTML = `[${refNumbers[key]}]`;
c.dataset.ref = key;
});
// -------------------------
// 3. If no citations → hide the entire section
// -------------------------
// if (citationCount === 0) {
// refSection.style.display = "none";
// return;
// }
// -------------------------
// 4. Build bibliography section
// -------------------------
for (const key in refNumbers) {
const n = refNumbers[key];
console.log(bib[key])
const li = document.createElement("p");
li.innerHTML = `<span>[${n}]</span> ${bib[key]}`;
refList.appendChild(li);
}
// Section stays visible only if citations exist
});
</script>
<style>
lemma {
display: block; /* behaves like <h3> */
margin-top: 1em; /* space before, like a line break */
font-weight: bold; /* match heading style */
font-size: 1.1em; /* approx h3 size (browser default) */
}
/* Define how lemma is displayed anywhere you use <lemma> */
lemma:before {
counter-increment: equation;
content: "Lemma " counter(heading) "." counter(equation) ": ";
font-weight: bold;
}
theorem {
display: block; /* behaves like <h3> */
margin-top: 1em; /* space before, like a line break */
font-weight: bold; /* match heading style */
font-size: 1.1em; /* approx h3 size (browser default) */
}
/* Define how lemma is displayed anywhere you use <lemma> */
theorem:before {
counter-increment: equation;
content: "Theorem " counter(heading) "." counter(equation) ": ";
font-weight: bold;
}
body {
counter-reset: heading equation;
font-family: 'Poppins', sans-serif;
}
h2:before {
counter-increment: heading;
content: counter(heading) " ";
counter-reset: subheading equation;
}
h3:before {
content: counter(heading) "." counter(subheading) " ";
counter-increment: subheading;
}
h2.no-ref::before {
counter-increment: none;
content: "";
}
</style>
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>
</head>
<body>
A biological insight <cite key="abc"></cite>
<div id="reference-section" style="font-size:1.1em">
<h2 class="no-ref">References</h2>
<div id="references"></div>
</div>
</body>
</html>