mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix by review comment
This commit is contained in:
parent
07e52ff22d
commit
7c7a563426
@ -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
|
||||
|
@ -567,6 +567,8 @@ class StandardDomain(Domain):
|
||||
if n.tagname == 'caption':
|
||||
sectname = clean_astext(n)
|
||||
break
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
# anonymous-only labels
|
||||
continue
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user