Skip to content

Commit fa8fe0d

Browse files
committed
Fix #77
1 parent 87360b1 commit fa8fe0d

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

src/py_semantic_taxonomy/adapters/routers/templates/base.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
88
<link rel="stylesheet" href="/static/css/tailwind.css">
99
<link rel="stylesheet" href="/static/css/pyst.css">
10+
<script>
11+
MathJax = {
12+
tex: {
13+
inlineMath: [['$', '$'], ['\\(', '\\)']],
14+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
15+
processEscapes: true,
16+
processEnvironments: true
17+
},
18+
options: {
19+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
20+
}
21+
};
22+
</script>
23+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
1024
</head>
1125
<body>
1226
<!-- Header -->

src/py_semantic_taxonomy/adapters/routers/templates/concept_scheme_view.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h2 class="text-lg font-medium" style="color: var(--text-color)">Concepts</h2>
6060
</td>
6161
<td class="px-6 py-4">
6262
<a href="{{ concept.url }}">
63-
<div class="text-sm line-clamp-2" style="color: var(--text-secondary)">
63+
<div class="text-sm line-clamp-2 mathjax-content" style="color: var(--text-secondary)">
6464
{% if concept.definitions|lang(language) %}
6565
{{ concept.definitions|lang(language)}}
6666
{% else %}
@@ -108,7 +108,7 @@ <h3 class="text-sm font-medium" style="color: var(--text-secondary)">IRI</h3>
108108
<!-- Description -->
109109
<div>
110110
<h3 class="text-sm font-medium" style="color: var(--text-secondary)">Description</h3>
111-
<div class="mt-1 text-sm" style="color: var(--text-color)">
111+
<div class="mt-1 text-sm mathjax-content" style="color: var(--text-color)">
112112
{% if concept_scheme.definitions|lang(language) %}
113113
{{ concept_scheme.definitions|lang(language)}}
114114
{% else %}
@@ -170,5 +170,14 @@ <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Notation</h
170170
iri_clicker.onclick = function(){
171171
navigator.clipboard.writeText("{{ concept_scheme.id_ }}").then(this.querySelector('#cs_iri_clicker_icon').classList.replace("fa-copy", "fa-check"))
172172
};
173+
174+
// Render MathJax for definition content
175+
document.addEventListener('DOMContentLoaded', function() {
176+
if (typeof MathJax !== 'undefined') {
177+
MathJax.typesetPromise([document.querySelectorAll('.mathjax-content')]).catch(function (err) {
178+
console.log('MathJax rendering error:', err);
179+
});
180+
}
181+
});
173182
</script>
174183
{% endblock %}

src/py_semantic_taxonomy/adapters/routers/templates/concept_schemes.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h1>Concept Schemes</h1>
5050
</td>
5151
<td class="px-6 py-4">
5252
<a href="{{ scheme.url }}">
53-
<div class="text-sm line-clamp-2" style="color: var(--text-secondary)">
53+
<div class="text-sm line-clamp-2 mathjax-content" style="color: var(--text-secondary)">
5454
{% if scheme.definitions|lang(language) %}
5555
{{ scheme.definitions|lang(language)}}
5656
{% else %}
@@ -81,4 +81,15 @@ <h1>Concept Schemes</h1>
8181
</div>
8282
</div>
8383
</div>
84+
85+
<script>
86+
// Render MathJax for definition content
87+
document.addEventListener('DOMContentLoaded', function() {
88+
if (typeof MathJax !== 'undefined') {
89+
MathJax.typesetPromise([document.querySelectorAll('.mathjax-content')]).catch(function (err) {
90+
console.log('MathJax rendering error:', err);
91+
});
92+
}
93+
});
94+
</script>
8495
{% endblock %}

src/py_semantic_taxonomy/adapters/routers/templates/concept_view.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1>{{ concept.pref_labels|lang(language) }}</h1>
2626
<h2 class="text-lg font-medium" style="color: var(--text-color)">Definition</h2>
2727
</div>
2828
<div class="px-4 py-5 sm:p-6" style="background-color: var(--nav-bg)">
29-
<div class="text-sm" style="color: var(--text-color)">
29+
<div class="text-sm mathjax-content" style="color: var(--text-color)">
3030
{% if concept.definitions|lang(language) %}
3131
{{ concept.definitions|lang(language) }}
3232
{% else %}
@@ -300,5 +300,14 @@ <h3 class="text-sm font-medium" style="color: var(--text-secondary)">Hidden Labe
300300
iri_clicker.onclick = function(){
301301
navigator.clipboard.writeText("{{ concept.id_ }}").then(this.querySelector('#concept_iri_clicker_icon').classList.replace("fa-copy", "fa-check"))
302302
};
303+
304+
// Render MathJax for definition content
305+
document.addEventListener('DOMContentLoaded', function() {
306+
if (typeof MathJax !== 'undefined') {
307+
MathJax.typesetPromise([document.querySelector('.mathjax-content')]).catch(function (err) {
308+
console.log('MathJax rendering error:', err);
309+
});
310+
}
311+
});
303312
</script>
304313
{% endblock %}

src/py_semantic_taxonomy/adapters/routers/templates/search.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,18 @@ <h3 class="text-lg font-medium mb-2" style="color: var(--text-color)">Start sear
119119
${definition ? `
120120
<div class="flex items-start">
121121
<i class="fas fa-info-circle mr-2 mt-0.5" style="color: var(--text-tertiary)"></i>
122-
<span class="text-xs" style="color: var(--text-secondary)">${definition}</span>
122+
<span class="text-xs mathjax-content" style="color: var(--text-secondary)">${definition}</span>
123123
</div>
124124
` : ''}
125125
</div>
126126
`;
127+
128+
// Render MathJax for dynamically loaded content
129+
if (typeof MathJax !== 'undefined') {
130+
MathJax.typesetPromise([infoDiv.querySelector('.mathjax-content')]).catch(function (err) {
131+
console.log('MathJax rendering error:', err);
132+
});
133+
}
127134
} else {
128135
infoDiv.innerHTML = '<span class="text-red-500 text-xs">Failed to load concept details</span>';
129136
}

0 commit comments

Comments
 (0)