mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4085 Failed PDF build from image in parsed-literal
This commit is contained in:
parent
e15e9a79b4
commit
dc129e0532
2
CHANGES
2
CHANGES
@ -16,6 +16,8 @@ Features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #4085: Failed PDF build from image in parsed-literal using ``:align:`` option
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
|
@ -1702,9 +1702,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:
|
||||
@ -1744,6 +1741,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
post.append(align_prepost[is_inline, attrs['align']][1])
|
||||
except KeyError:
|
||||
pass
|
||||
if self.in_parsed_literal:
|
||||
pre.append('\\begingroup\\sphinxunactivateextrasandspace\\relax ')
|
||||
post.append('\\endgroup ')
|
||||
if not is_inline:
|
||||
pre.append('\n\\noindent')
|
||||
post.append('\n')
|
||||
|
13
tests/roots/test-image-in-parsed-literal/conf.py
Normal file
13
tests/roots/test-image-in-parsed-literal/conf.py
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
rst_epilog = '''
|
||||
.. |picture| image:: pic.png
|
||||
:width: 15pt
|
||||
:scale: 200%
|
||||
:align: middle
|
||||
:alt: alternative_text
|
||||
'''
|
||||
|
9
tests/roots/test-image-in-parsed-literal/index.rst
Normal file
9
tests/roots/test-image-in-parsed-literal/index.rst
Normal file
@ -0,0 +1,9 @@
|
||||
test-image-in-parsed-literal
|
||||
============================
|
||||
|
||||
Dummy text
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
|picture|
|
||||
|
BIN
tests/roots/test-image-in-parsed-literal/pic.png
Normal file
BIN
tests/roots/test-image-in-parsed-literal/pic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 B |
@ -1029,3 +1029,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 (r'\begingroup\sphinxunactivateextrasandspace\relax \raisebox{-0.5\height}'
|
||||
r'{\scalebox{2.000000}{\sphinxincludegraphics[width=15bp]{{pic}.png}}}'
|
||||
r'\endgroup ') in result
|
||||
|
Loading…
Reference in New Issue
Block a user