diff --git a/CHANGES b/CHANGES index 9269d035c..e27a94ff6 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugs fixed * #4817: wrong URLs on warning messages * #4784: latex: :confval:`latex_show_urls` assigns incorrect footnote numbers if hyperlinks exists inside substitutions +* #4837: latex with class memoir Error: Font command ``\sf`` is not supported * #4803: latex: too slow in proportion to number of auto numbered footnotes Testing @@ -61,6 +62,7 @@ Bugs fixed * #1435: qthelp builder should htmlescape keywords * epub: Fix docTitle elements of toc.ncx is not escaped * #4520: apidoc: Subpackage not in toc (introduced in 1.6.6) now fixed +* #4767: html: search highlighting breaks mathjax equations Release 1.7.1 (released Feb 23, 2018) ===================================== diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 05d5dc290..5d8ec876e 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -20,14 +20,14 @@ from sphinx.locale import _ def html_visit_math(self, node): - self.body.append(self.starttag(node, 'span', '', CLASS='math notranslate')) + self.body.append(self.starttag(node, 'span', '', CLASS='math notranslate nohighlight')) self.body.append(self.encode(node['latex']) + '') raise nodes.SkipNode def html_visit_displaymath(self, node): if node['nowrap']: - self.body.append(self.starttag(node, 'div', CLASS='math notranslate')) + self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) self.body.append(self.encode(node['latex'])) self.body.append('') raise nodes.SkipNode @@ -40,7 +40,7 @@ def html_visit_displaymath(self, node): self.body.append('(%s)' % number) self.add_permalink_ref(node, _('Permalink to this equation')) self.body.append('') - self.body.append(self.starttag(node, 'div', CLASS='math notranslate')) + self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) else: # but only once! self.body.append('
') diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py index 6c5d0a642..bb9964fa8 100644 --- a/sphinx/ext/mathjax.py +++ b/sphinx/ext/mathjax.py @@ -21,7 +21,7 @@ from sphinx.locale import _ def html_visit_math(self, node): - self.body.append(self.starttag(node, 'span', '', CLASS='math notranslate')) + self.body.append(self.starttag(node, 'span', '', CLASS='math notranslate nohighlight')) self.body.append(self.builder.config.mathjax_inline[0] + self.encode(node['latex']) + self.builder.config.mathjax_inline[1] + '') @@ -29,7 +29,7 @@ def html_visit_math(self, node): def html_visit_displaymath(self, node): - self.body.append(self.starttag(node, 'div', CLASS='math notranslate')) + self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) if node['nowrap']: self.body.append(self.encode(node['latex'])) self.body.append('
') diff --git a/sphinx/themes/basic/static/doctools.js_t b/sphinx/themes/basic/static/doctools.js_t index b261a44f3..1dca47404 100644 --- a/sphinx/themes/basic/static/doctools.js_t +++ b/sphinx/themes/basic/static/doctools.js_t @@ -70,7 +70,9 @@ jQuery.fn.highlightText = function(text, className) { if (node.nodeType === 3) { var val = node.nodeValue; var pos = val.toLowerCase().indexOf(text); - if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { + if (pos >= 0 && + !jQuery(node.parentNode).hasClass(className) && + !jQuery(node.parentNode).hasClass("nohighlight")) { var span; var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); if (isInSVG) { diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 24c37b96a..8dbe58963 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -508,7 +508,10 @@ class LaTeXTranslator(nodes.NodeVisitor): if builder.config.language \ and 'fncychap' not in builder.config.latex_elements: # use Sonny style if any language specified - self.elements['fncychap'] = '\\usepackage[Sonny]{fncychap}' + self.elements['fncychap'] = ('\\usepackage[Sonny]{fncychap}\n' + '\\ChNameVar{\\Large\\normalfont' + '\\sffamily}\n\\ChTitleVar{\\Large' + '\\normalfont\\sffamily}') self.babel = ExtBabel(builder.config.language) if builder.config.language and not self.babel.is_supported_language(): diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 755a9e955..28ce094a8 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -35,19 +35,19 @@ def test_jsmath(app, status, warning): app.builder.build_all() content = (app.outdir / 'math.html').text() - assert '
\na^2 + b^2 = c^2
' in content - assert ('
\n\\begin{split}a + 1 < b\\end{split}
' - in content) + assert '
\na^2 + b^2 = c^2
' in content + assert ('
\n\\begin{split}a + 1 < ' + 'b\\end{split}
' in content) assert (u'(1)\xb6' - u'
\ne^{i\\pi} = 1
' - in content) + u'
' + '\ne^{i\\pi} = 1
' in content) assert (u'(2)\xb6' - u'
\n' + u'
\n' u'e^{ix} = \\cos x + i\\sin x
' in content) - assert '
\nn \\in \\mathbb N
' in content - assert '
\na + 1 < b
' in content + assert '
\nn \\in \\mathbb N
' in content + assert '
\na + 1 < b
' in content @pytest.mark.skipif(not has_binary('dvipng'), @@ -91,7 +91,7 @@ def test_mathjax_align(app, status, warning): app.builder.build_all() content = (app.outdir / 'index.html').text() - html = (r'
\s*' + html = (r'
\s*' r'\\\[ \\begin\{align\}\\begin\{aligned\}S \&= \\pi r\^2\\\\' r'V \&= \\frac\{4\}\{3\} \\pi r\^3\\end\{aligned\}\\end\{align\} \\\]
') assert re.search(html, content, re.S) @@ -104,7 +104,7 @@ def test_math_number_all_mathjax(app, status, warning): app.builder.build_all() content = (app.outdir / 'index.html').text() - html = (r'
\s*' + html = (r'
\s*' r'\(1\)\xb6\\\[a\^2\+b\^2=c\^2\\\]
') assert re.search(html, content, re.S) @@ -169,7 +169,7 @@ def test_mathjax_numfig_html(app, status, warning): app.builder.build_all() content = (app.outdir / 'math.html').text() - html = ('
\n' + html = ('
\n' '(1.2)') assert html in content html = ('

Referencing equation