Fix combination of figure directive options; width, figwidth and align (ref: #2595)

This commit is contained in:
Takeshi KOMIYA
2016-05-30 13:13:38 +09:00
parent da3d368961
commit 24beece2a3
4 changed files with 17 additions and 4 deletions

View File

@@ -1431,7 +1431,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
node.children[0]['ids']):
ids += self.hypertarget(node.children[0]['ids'][0], anchor=False)
if node.get('align', '') in ('left', 'right'):
if 'width' in node[0]:
if 'width' in node:
length = width_to_latex_length(node['width'])
elif 'width' in node[0]:
length = width_to_latex_length(node[0]['width'])
else:
length = '0pt'

View File

@@ -246,6 +246,12 @@ Figures
figure with align & figwidth option
.. figure:: rimg.png
:align: right
:width: 3cm
figure with align & width option
Version markup
--------------

View File

@@ -31,14 +31,14 @@ http://www.python.org/logo.png
reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
:encoding: option\\n?
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png
(%(root)s/markup.txt:373: WARNING: invalid single index entry u'')?
(%(root)s/markup.txt:379: WARNING: invalid single index entry u'')?
(%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \
with "\\?": b?'here: >>>(\\\\|/)xbb<<<'
)?"""
HTML_WARNINGS = ENV_WARNINGS + """\
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
%(root)s/markup.txt:285: WARNING: Could not lex literal_block as "c". Highlighting skipped.
%(root)s/markup.txt:291: WARNING: Could not lex literal_block as "c". Highlighting skipped.
%(root)s/footnote.txt:60: WARNING: citation not found: missing
%(root)s/markup.txt:164: WARNING: unknown option: &option
"""

View File

@@ -27,7 +27,7 @@ LATEX_WARNINGS = ENV_WARNINGS + """\
%(root)s/markup.txt:164: WARNING: unknown option: &option
%(root)s/footnote.txt:60: WARNING: citation not found: missing
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
%(root)s/markup.txt:285: WARNING: Could not lex literal_block as "c". Highlighting skipped.
%(root)s/markup.txt:291: WARNING: Could not lex literal_block as "c". Highlighting skipped.
"""
if PY3:
@@ -119,6 +119,11 @@ def test_writer(app, status, warning):
'\\includegraphics{{rimg}.png}\n\\caption{figure with align \\& figwidth option}'
'\\label{markup:id8}\\end{wrapfigure}' in result)
assert ('\\begin{wrapfigure}{r}{3cm}\n\\centering\n'
'\\includegraphics[width=3cm]{{rimg}.png}\n'
'\\caption{figure with align \\& width option}'
'\\label{markup:id9}\\end{wrapfigure}' in result)
@with_app(buildername='latex', freshenv=True, # use freshenv to check warnings
confoverrides={'latex_documents': [