28
28
settings_overrides=settings_overrides)
29
29
# Encoding a euro sign with latin1 doesn't work, so the
30
30
# xmlcharrefreplace handler is used.
31
self.assertNotEqual(result.find(b('EUR = €')), -1)
31
self.assertIn(b('EUR = €'), result)
33
class MathTestCase(DocutilsTestSupport.StandardTestCase):
35
"""Attention: This class tests the current implementation of maths support
36
which is open to change in future Docutils releases. """
38
settings_overrides={'_disable_config': True,}
39
mathjax_script = '<script type="text/javascript" src="%s">'
40
default_mathjax_url = ('http://cdn.mathjax.org/mathjax/latest/MathJax.js'
41
'?config=TeX-AMS-MML_HTMLorMML')
42
custom_mathjax_url = ('file:///usr/share/javascript/mathjax/MathJax.js'
43
'?config=TeX-AMS-MML_HTMLorMML')
46
def test_math_output_default(self):
47
# Currently MathJax with default URL. Likely to change to HTML!
48
mysettings = self.settings_overrides
49
head = core.publish_parts(self.data, writer_name='html4css1',
50
settings_overrides=mysettings)['head']
51
self.assertIn(self.mathjax_script % self.default_mathjax_url, head)
53
def test_math_output_mathjax(self):
54
# Explicitly specifying math_output=MathJax, case insensitively
55
# use default MathJax URL
56
mysettings = self.settings_overrides.copy()
57
mysettings.update({'math_output': 'MathJax'})
58
head = core.publish_parts(self.data, writer_name='html4css1',
59
settings_overrides=mysettings)['head']
60
self.assertIn(self.mathjax_script % self.default_mathjax_url, head)
62
def test_math_output_mathjax_custom(self):
63
# Customizing MathJax URL
64
mysettings = self.settings_overrides.copy()
65
mysettings.update({'math_output':
66
'mathjax %s' % self.custom_mathjax_url})
67
head = core.publish_parts(self.data, writer_name='html4css1',
68
settings_overrides=mysettings)['head']
69
self.assertIn(self.mathjax_script % self.custom_mathjax_url, head)
71
def test_math_output_html(self):
72
# There should be no MathJax script when math_output is not MathJax
73
mysettings = self.settings_overrides.copy()
74
mysettings.update({'math_output': 'HTML'})
75
head = core.publish_parts(self.data, writer_name='html4css1',
76
settings_overrides=mysettings)['head']
77
self.assertNotIn('MathJax.js', head)
79
def test_math_output_mathjax_no_math(self):
80
mysettings = self.settings_overrides.copy()
81
mysettings.update({'math_output': 'MathJax'})
82
# There should be no math script when text does not contain math
83
head = core.publish_parts('No math.', writer_name='html4css1')['head']
84
self.assertNotIn('MathJax', head)
34
87
if __name__ == '__main__':