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):
|
def container_wrapper(directive, literal_node, caption):
|
||||||
container_node = nodes.container('', literal_block=True)
|
caption_node = nodes.caption()
|
||||||
|
|
||||||
parsed = nodes.Element()
|
|
||||||
directive.state.nested_parse(ViewList([caption], source=''),
|
directive.state.nested_parse(ViewList([caption], source=''),
|
||||||
directive.content_offset, parsed)
|
directive.content_offset, caption_node)
|
||||||
caption_node = nodes.caption(parsed[0].rawsource, '',
|
|
||||||
*parsed[0].children)
|
container_node = nodes.container('', literal_block=True)
|
||||||
caption_node.source = parsed[0].source
|
|
||||||
caption_node.line = parsed[0].line
|
|
||||||
container_node += caption_node
|
container_node += caption_node
|
||||||
container_node += literal_node
|
container_node += literal_node
|
||||||
return container_node
|
return container_node
|
||||||
|
@ -567,6 +567,8 @@ class StandardDomain(Domain):
|
|||||||
if n.tagname == 'caption':
|
if n.tagname == 'caption':
|
||||||
sectname = clean_astext(n)
|
sectname = clean_astext(n)
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
# anonymous-only labels
|
# anonymous-only labels
|
||||||
continue
|
continue
|
||||||
|
@ -1500,7 +1500,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
ids = ''
|
ids = ''
|
||||||
for id in self.next_literal_ids:
|
for id in self.next_literal_ids:
|
||||||
ids += self.hypertarget(id, anchor=False)
|
ids += self.hypertarget(id, anchor=False)
|
||||||
self.next_figure_ids.clear()
|
self.next_literal_ids.clear()
|
||||||
self.body.append('\n\\begin{literal-block}' + ids)
|
self.body.append('\n\\begin{literal-block}' + ids)
|
||||||
|
|
||||||
def depart_container(self, node):
|
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):
|
def test_code_block_caption_latex(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
latex = (app.outdir / 'Python.tex').text()
|
latex = (app.outdir / 'Python.tex').text()
|
||||||
caption = '\\caption{caption \\emph{test} rb}'
|
caption = '\\caption{\ncaption \\emph{test} rb\n}'
|
||||||
assert caption in latex
|
assert caption in latex
|
||||||
|
|
||||||
|
|
||||||
@ -107,5 +107,5 @@ def test_literalinclude_caption_html(app, status, warning):
|
|||||||
def test_literalinclude_caption_latex(app, status, warning):
|
def test_literalinclude_caption_latex(app, status, warning):
|
||||||
app.builder.build('index')
|
app.builder.build('index')
|
||||||
latex = (app.outdir / 'Python.tex').text()
|
latex = (app.outdir / 'Python.tex').text()
|
||||||
caption = '\\caption{caption \\textbf{test} py}'
|
caption = '\\caption{\ncaption \\textbf{test} py\n}'
|
||||||
assert caption in latex
|
assert caption in latex
|
||||||
|
Loading…
Reference in New Issue
Block a user