diff --git a/CHANGES b/CHANGES index 116857e81..85f909712 100644 --- a/CHANGES +++ b/CHANGES @@ -95,6 +95,10 @@ Features added Bugs fixed ---------- +* #4085: Failed PDF build from image in parsed-literal using ``:align:`` option +* #4100: Remove debug print from autodoc extension +* #3987: Changing theme from alabaster causes HTML build to fail + Testing -------- diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 21cfbe545..e8586943f 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -716,7 +716,6 @@ class Documenter(object): # keep documented attributes keep = True isattr = True - print(membername, keep) elif want_all and membername.startswith('_'): # ignore members whose name starts with _ by default keep = self.options.private_members and \ diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index bd2031079..98d42c4ff 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1700,9 +1700,6 @@ class LaTeXTranslator(nodes.NodeVisitor): pre = [] # type: List[unicode] # in reverse order post = [] # type: List[unicode] - if self.in_parsed_literal: - pre = ['\\begingroup\\sphinxunactivateextrasandspace\\relax '] - post = ['\\endgroup '] include_graphics_options = [] is_inline = self.is_inline(node) if 'width' in attrs: @@ -1742,6 +1739,9 @@ class LaTeXTranslator(nodes.NodeVisitor): post.append(align_prepost[is_inline, attrs['align']][1]) except KeyError: pass + if self.in_parsed_literal: + pre.append('{\\sphinxunactivateextrasandspace ') + post.append('}') if not is_inline: pre.append('\n\\noindent') post.append('\n') diff --git a/tests/roots/test-image-in-parsed-literal/conf.py b/tests/roots/test-image-in-parsed-literal/conf.py new file mode 100644 index 000000000..d208b8385 --- /dev/null +++ b/tests/roots/test-image-in-parsed-literal/conf.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' +exclude_patterns = ['_build'] + +rst_epilog = ''' +.. |picture| image:: pic.png + :height: 1cm + :scale: 200% + :align: middle + :alt: alternative_text +''' + diff --git a/tests/roots/test-image-in-parsed-literal/index.rst b/tests/roots/test-image-in-parsed-literal/index.rst new file mode 100644 index 000000000..80e1008e1 --- /dev/null +++ b/tests/roots/test-image-in-parsed-literal/index.rst @@ -0,0 +1,9 @@ +test-image-in-parsed-literal +============================ + +Dummy text + +.. parsed-literal:: + + |picture|\ AFTER + diff --git a/tests/roots/test-image-in-parsed-literal/pic.png b/tests/roots/test-image-in-parsed-literal/pic.png new file mode 100644 index 000000000..fda6cd29e Binary files /dev/null and b/tests/roots/test-image-in-parsed-literal/pic.png differ diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index bb4e4f435..b58ee09c9 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -1028,3 +1028,13 @@ def test_latex_index(app, status, warning): result = (app.outdir / 'Python.tex').text(encoding='utf8') assert 'A \\index{famous}famous \\index{equation}equation:\n' in result assert '\n\\index{Einstein}\\index{relativity}\\ignorespaces \nand' in result + + +@pytest.mark.sphinx('latex', testroot='image-in-parsed-literal') +def test_latex_image_in_parsed_literal(app, status, warning): + app.builder.build_all() + + result = (app.outdir / 'Python.tex').text(encoding='utf8') + assert ('{\\sphinxunactivateextrasandspace \\raisebox{-0.5\height}' + '{\\scalebox{2.000000}{\\sphinxincludegraphics[height=1cm]{{pic}.png}}}' + '}AFTER') in result