Skip to content

Commit ac3da9e

Browse files
committed
fix(mathjax): remove redundant dollar delimiter config and detection
Dollar delimiters ($...$, $$...$$) are MathJax 3 defaults, so explicit config is redundant. Remove them from config, inline detection, and tests, and simplify the tag-detection logic (no remaining self-matching pairs).
1 parent 7520d25 commit ac3da9e

10 files changed

Lines changed: 1 addition & 38 deletions

File tree

cms/djangoapps/pipeline_js/js/xmodule.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ define(
1919
window.MathJax = {
2020
tex: {
2121
inlineMath: [
22-
['$', '$'],
2322
['\\(', '\\)'],
2423
['[mathjaxinline]', '[/mathjaxinline]']
2524
],
2625
displayMath: [
27-
['$$', '$$'],
2826
['\\[', '\\]'],
2927
['[mathjax]', '[/mathjax]']
3028
],

cms/static/cms/js/require-config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@
5050
window.MathJax = {
5151
tex: {
5252
inlineMath: [
53-
['$', '$'],
5453
['\\(', '\\)'],
5554
['[mathjaxinline]', '[/mathjaxinline]']
5655
],
5756
displayMath: [
58-
['$$', '$$'],
5957
['\\[', '\\]'],
6058
['[mathjax]', '[/mathjax]']
6159
],

cms/static/cms/js/spec/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
window.MathJax = {
2424
tex: {
2525
inlineMath: [
26-
['$', '$'],
2726
['\\(', '\\)'],
2827
['[mathjaxinline]', '[/mathjaxinline]']
2928
],
3029
displayMath: [
31-
['$$', '$$'],
3230
['\\[', '\\]'],
3331
['[mathjax]', '[/mathjax]']
3432
],

cms/static/cms/js/spec/main_squire.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
window.MathJax = {
1010
tex: {
1111
inlineMath: [
12-
['$', '$'],
1312
['\\(', '\\)'],
1413
['[mathjaxinline]', '[/mathjaxinline]']
1514
],
1615
displayMath: [
17-
['$$', '$$'],
1816
['\\[', '\\]'],
1917
['[mathjax]', '[/mathjax]']
2018
],

common/static/common/js/discussion/mathjax_include.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ if (typeof MathJax === 'undefined') {
22
window.MathJax = {
33
tex: {
44
inlineMath: [
5-
['$', '$'],
65
['\\(', '\\)'],
76
['[mathjaxinline]', '[/mathjaxinline]']
87
],
98
displayMath: [
10-
['$$', '$$'],
119
['\\[', '\\]'],
1210
['[mathjax]', '[/mathjax]']
1311
],

common/templates/mathjax_include.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@
4343
window.MathJax = {
4444
tex: {
4545
inlineMath: [
46-
['$', '$'],
4746
["\\(","\\)"],
4847
['[mathjaxinline]','[/mathjaxinline]']
4948
],
5049
displayMath: [
51-
['$$', '$$'],
5250
["\\[","\\]"],
5351
['[mathjax]','[/mathjax]']
5452
],

common/templates/xblock_v2/xblock_iframe.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@
126126
window.MathJax = {
127127
tex: {
128128
inlineMath: [
129-
['$', '$'],
130129
["\\(","\\)"],
131130
['[mathjaxinline]','[/mathjaxinline]']
132131
],
133132
displayMath: [
134-
['$$', '$$'],
135133
["\\[","\\]"],
136134
['[mathjax]','[/mathjax]']
137135
],

lms/djangoapps/courseware/tests/test_views.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,8 +2811,6 @@ def setUp(self):
28112811
display_name='Vertical with No Mathjax HTML',
28122812
)
28132813
MATHJAX_TAG_PAIRS = [
2814-
("$", "$"),
2815-
("$$", "$$"),
28162814
(r"\(", r"\)"),
28172815
(r"\[", r"\]"),
28182816
("[mathjaxinline]", "[/mathjaxinline]"),
@@ -2833,12 +2831,6 @@ def setUp(self):
28332831
display_name="HTML Without Mathjax",
28342832
data="<p>I talk about mathjax, but I have no actual Math!</p>",
28352833
)
2836-
self.html_with_lone_dollar = BlockFactory.create(
2837-
category='html',
2838-
parent_location=self.no_math_vertical.location,
2839-
display_name="HTML With Lone Dollar",
2840-
data="<p>Price: $5</p>",
2841-
)
28422834

28432835
self.course_key = self.course.id
28442836
self.user = UserFactory(username='staff_user', profile__country='AX', is_staff=True)
@@ -2857,8 +2849,6 @@ def test_mathjax_detection(self):
28572849
response = self.client.get(url)
28582850
assert response.status_code == 200
28592851
assert b"window.MathJax" in response.content
2860-
assert b"['$', '$']" in response.content
2861-
assert b"['$$', '$$']" in response.content
28622852

28632853
# Check the one without Math...
28642854
url = reverse("render_xblock", kwargs={
@@ -2868,14 +2858,6 @@ def test_mathjax_detection(self):
28682858
assert response.status_code == 200
28692859
assert b"window.MathJax" not in response.content
28702860

2871-
# Check lone dollar sign isn't mistaken for MathJax
2872-
url = reverse("render_xblock", kwargs={
2873-
'usage_key_string': str(self.html_with_lone_dollar.location)
2874-
})
2875-
response = self.client.get(url)
2876-
assert response.status_code == 200
2877-
assert b"window.MathJax" not in response.content
2878-
28792861
# The containing vertical should still return MathJax (for now)
28802862
url = reverse("render_xblock", kwargs={
28812863
'usage_key_string': str(self.no_math_vertical.location)

lms/djangoapps/courseware/views/views.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,8 +1802,6 @@ def has_mathjax_content(self):
18021802
# The following pairs are used to mark Mathjax syntax in XBlocks. There
18031803
# are other options for the wiki, but we don't worry about those here.
18041804
MATHJAX_TAG_PAIRS = [
1805-
("$", "$"),
1806-
("$$", "$$"),
18071805
(r"\(", r"\)"),
18081806
(r"\[", r"\]"),
18091807
("[mathjaxinline]", "[/mathjaxinline]"),
@@ -1812,8 +1810,7 @@ def has_mathjax_content(self):
18121810
content = self.fragment.body_html()
18131811
for (start_tag, end_tag) in MATHJAX_TAG_PAIRS:
18141812
if start_tag in content and end_tag in content:
1815-
if start_tag != end_tag or content.count(start_tag) >= 2:
1816-
return True
1813+
return True
18171814

18181815
return False
18191816

lms/static/lms/js/spec/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
window.MathJax = {
1010
tex: {
1111
inlineMath: [
12-
['$', '$'],
1312
['\\(', '\\)'],
1413
['[mathjaxinline]', '[/mathjaxinline]']
1514
],
1615
displayMath: [
17-
['$$', '$$'],
1816
['\\[', '\\]'],
1917
['[mathjax]', '[/mathjax]']
2018
],

0 commit comments

Comments
 (0)