Skip to content

Commit e90e39c

Browse files
committed
Render MathJax in clarifications
1 parent 2bdec13 commit e90e39c

File tree

9 files changed

+38
-2
lines changed

9 files changed

+38
-2
lines changed

webapp/public/js/domjudge.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ function previewClarification($input, $previewDiv) {
945945
}
946946
}).done(function (data) {
947947
$previewDiv.html(data.html);
948+
MathJax.typesetPromise([document.getElementById($previewDiv[0].id)]);
948949
});
949950
}
950951
}

webapp/public/js/tex-chtml.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../node_modules/mathjax/tex-chtml.js

webapp/public/mathjax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../node_modules/mathjax

webapp/public/mathjaxfonts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../node_modules/@mathjax/mathjax-newcm-font/chtml/woff2

webapp/templates/base.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<script src="{{ asset("js/jquery.min.js") }}"></script>
1414
<script src="{{ asset("js/jquery.debounce.min.js") }}"></script>
1515
<script src="{{ asset("js/bootstrap.bundle.min.js") }}"></script>
16+
{% include 'partials/mathjaxhead.html.twig' %}
1617

1718
<script src="{{ asset("js/domjudge.js") }}"></script>
1819
{% for file in customAssetFiles('js') %}

webapp/templates/jury/export/layout.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
color: darkgrey;
109109
}
110110
</style>
111+
{% include 'partials/mathjaxhead.html.twig' %}
111112
</head>
112113
<body>
113114
<main role="main" class="">
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script>
2+
window.MathJax = {
3+
tex: {
4+
inlineMath: [['$', '$']]
5+
},
6+
chtml: {
7+
fontURL: '{{ app.request.basePath }}/mathjaxfonts',
8+
scale: 1.0
9+
},
10+
loader: {
11+
paths: {
12+
mathjax: '{{ app.request.basePath }}/mathjax',
13+
'@mathjax': '{{ app.request.basePath }}/mathjax'
14+
},
15+
// Optional: reinforce that @mathjax modules resolve under the same base
16+
source: {
17+
'@mathjax': '[mathjax]'
18+
},
19+
load: ['input/tex', 'output/chtml']
20+
}
21+
};
22+
</script>
23+
<script src="{{ app.request.basePath }}/mathjax/tex-chtml.js"></script>

webapp/templates/team/partials/clarification_content.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424
{{ form_end(form) }}
2525
</div>
2626
</div>
27+
28+
<script>
29+
MathJax.typeset([document.getElementsByClassName('card-body')]);
30+
</script>

webapp/templates/team/partials/clarification_list.html.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
</td>
4141
{% endif %}
4242

43-
<td>
43+
<td class="clarification-text">
4444
{%- if clarification.sender is null and clarification.recipient is not null %}
4545
you
4646
{%- else %}
4747
all
4848
{%- endif -%}
4949
</td>
5050

51-
<td>
51+
<td class="clarification-text">
5252
<a data-ajax-modal data-ajax-modal-after="markSeen" href="{{ link }}">
5353
<i>{{ clarification.summary
5454
| markdown_to_html
@@ -57,6 +57,9 @@
5757
| raw
5858
}}</i>
5959
</a>
60+
<script>
61+
MathJax.typeset([document.getElementsByClassName('card-body')]);
62+
</script>
6063
</td>
6164
</tr>
6265
{%- endfor %}

0 commit comments

Comments
 (0)