Fix by review comment

This commit is contained in:
tk0miya 2014-09-26 20:15:17 +09:00
parent 07e52ff22d
commit 7c7a563426
4 changed files with 9 additions and 11 deletions

View File

@ -63,15 +63,11 @@ def dedent_lines(lines, dedent):
def container_wrapper(directive, literal_node, caption):
container_node = nodes.container('', literal_block=True)
parsed = nodes.Element()
caption_node = nodes.caption()
directive.state.nested_parse(ViewList([caption], source=''),
directive.content_offset, parsed)
caption_node = nodes.caption(parsed[0].rawsource, '',
*parsed[0].children)
caption_node.source = parsed[0].source
caption_node.line = parsed[0].line
directive.content_offset, caption_node)
container_node = nodes.container('', literal_block=True)
container_node += caption_node
container_node += literal_node
return container_node

View File

@ -567,6 +567,8 @@ class StandardDomain(Domain):
if n.tagname == 'caption':
sectname = clean_astext(n)
break
else:
continue
else:
# anonymous-only labels
continue

View File

@ -1500,7 +1500,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
ids = ''
for id in self.next_literal_ids:
ids += self.hypertarget(id, anchor=False)
self.next_figure_ids.clear()
self.next_literal_ids.clear()
self.body.append('\n\\begin{literal-block}' + ids)
def depart_container(self, node):

View File

@ -61,7 +61,7 @@ def test_code_block_caption_html(app, status, warning):
def test_code_block_caption_latex(app, status, warning):
app.builder.build_all()
latex = (app.outdir / 'Python.tex').text()
caption = '\\caption{caption \\emph{test} rb}'
caption = '\\caption{\ncaption \\emph{test} rb\n}'
assert caption in latex
@ -107,5 +107,5 @@ def test_literalinclude_caption_html(app, status, warning):
def test_literalinclude_caption_latex(app, status, warning):
app.builder.build('index')
latex = (app.outdir / 'Python.tex').text()
caption = '\\caption{caption \\textbf{test} py}'
caption = '\\caption{\ncaption \\textbf{test} py\n}'
assert caption in latex