Fix broken numeric reference in PDF hyperlinks to "Listing " code-blocks

The `\label` is now inserted into the caption on top of the Verbatim,
and `\ref` will work as expected. No need for `\phantomsection`.

	modified:   sphinx/writers/latex.py
	modified:   tests/test_directive_code.py
This commit is contained in:
jfbu
2016-04-03 16:21:28 +02:00
parent 6123ea49e5
commit a1647b6bb9
2 changed files with 8 additions and 7 deletions

View File

@@ -64,7 +64,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(encoding='utf-8')
caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{caption \\emph{test} rb}'
caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{\label{caption:caption-test-rb}caption \\emph{test} rb}'
assert caption in latex
@@ -229,7 +229,7 @@ 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(encoding='utf-8')
caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{caption \\textbf{test} py}'
caption = '\\SphinxSetupCaptionForVerbatim{literal-block}{\label{caption:caption-test-py}caption \\textbf{test} py}'
assert caption in latex