mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-19 01:14:45 -05:00
Fix #2226: Math is not HTML-encoded when :nowrap: is given (jsmath, mathjax)
This commit is contained in:
@@ -46,6 +46,7 @@ Bugs fixed
|
|||||||
* #2198,#2205: ``make gettext`` generate broken msgid for definition lists.
|
* #2198,#2205: ``make gettext`` generate broken msgid for definition lists.
|
||||||
* #2062: Escape characters in doctests are treated incorrectly with Python 2.
|
* #2062: Escape characters in doctests are treated incorrectly with Python 2.
|
||||||
* #2225: Fix if the option does not begin with dash, linking is not performed
|
* #2225: Fix if the option does not begin with dash, linking is not performed
|
||||||
|
* #2226: Fix math is not HTML-encoded when :nowrap: is given (jsmath, mathjax)
|
||||||
|
|
||||||
Release 1.3.3 (released Dec 2, 2015)
|
Release 1.3.3 (released Dec 2, 2015)
|
||||||
====================================
|
====================================
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def html_visit_math(self, node):
|
|||||||
def html_visit_displaymath(self, node):
|
def html_visit_displaymath(self, node):
|
||||||
if node['nowrap']:
|
if node['nowrap']:
|
||||||
self.body.append(self.starttag(node, 'div', CLASS='math'))
|
self.body.append(self.starttag(node, 'div', CLASS='math'))
|
||||||
self.body.append(node['latex'])
|
self.body.append(self.encode(node['latex']))
|
||||||
self.body.append('</div>')
|
self.body.append('</div>')
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
for i, part in enumerate(node['latex'].split('\n\n')):
|
for i, part in enumerate(node['latex'].split('\n\n')):
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def html_visit_displaymath(self, node):
|
|||||||
self.body.append(self.starttag(node, 'div', CLASS='math'))
|
self.body.append(self.starttag(node, 'div', CLASS='math'))
|
||||||
if node['nowrap']:
|
if node['nowrap']:
|
||||||
self.body.append(self.builder.config.mathjax_display[0] +
|
self.body.append(self.builder.config.mathjax_display[0] +
|
||||||
node['latex'] +
|
self.encode(node['latex']) +
|
||||||
self.builder.config.mathjax_display[1])
|
self.builder.config.mathjax_display[1])
|
||||||
self.body.append('</div>')
|
self.body.append('</div>')
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|||||||
+6
-1
@@ -7,7 +7,7 @@ This is inline math: :math:`a^2 + b^2 = c^2`.
|
|||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
a^2 + b^2 = c^2
|
a + 1 < b
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
:label: foo
|
:label: foo
|
||||||
@@ -23,4 +23,9 @@ This is inline math: :math:`a^2 + b^2 = c^2`.
|
|||||||
|
|
||||||
n \in \mathbb N
|
n \in \mathbb N
|
||||||
|
|
||||||
|
.. math::
|
||||||
|
:nowrap:
|
||||||
|
|
||||||
|
a + 1 < b
|
||||||
|
|
||||||
Referencing equation :eq:`foo`.
|
Referencing equation :eq:`foo`.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from six import PY3, iteritems
|
|||||||
from six.moves import html_entities
|
from six.moves import html_entities
|
||||||
|
|
||||||
from sphinx import __display_version__
|
from sphinx import __display_version__
|
||||||
from util import remove_unicode_literals, gen_with_app
|
from util import remove_unicode_literals, gen_with_app, with_app
|
||||||
from etree13 import ElementTree as ET
|
from etree13 import ElementTree as ET
|
||||||
|
|
||||||
|
|
||||||
@@ -929,3 +929,18 @@ def test_numfig_with_secnum_depth(app, status, warning):
|
|||||||
|
|
||||||
for xpath, check, be_found in paths:
|
for xpath, check, be_found in paths:
|
||||||
yield check_xpath, etree, fname, xpath, check, be_found
|
yield check_xpath, etree, fname, xpath, check, be_found
|
||||||
|
|
||||||
|
|
||||||
|
@with_app(buildername='html')
|
||||||
|
def test_jsmath(app, status, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
content = (app.outdir / 'math.html').text()
|
||||||
|
|
||||||
|
assert '<div class="math">\na^2 + b^2 = c^2</div>' in content
|
||||||
|
assert '<div class="math">\n\\begin{split}a + 1 < b\\end{split}</div>' in content
|
||||||
|
assert ('<span class="eqno">(1)</span><div class="math" id="equation-foo">\n'
|
||||||
|
'e^{i\\pi} = 1</div>' in content)
|
||||||
|
assert ('<span class="eqno">(2)</span><div class="math">\n'
|
||||||
|
'e^{ix} = \\cos x + i\\sin x</div>' in content)
|
||||||
|
assert '<div class="math">\nn \\in \\mathbb N</div>' in content
|
||||||
|
assert '<div class="math">\na + 1 < b</div>' in content
|
||||||
|
|||||||
Reference in New Issue
Block a user