mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2931: code-block directive with same :caption: causes warning of duplicate target
This commit is contained in:
@@ -56,7 +56,7 @@ def test_code_block_caption_html(app, status, warning):
|
||||
caption = (u'<div class="code-block-caption">'
|
||||
u'<span class="caption-number">Listing 1 </span>'
|
||||
u'<span class="caption-text">caption <em>test</em> rb'
|
||||
u'</span><a class="headerlink" href="#caption-test-rb" '
|
||||
u'</span><a class="headerlink" href="#id1" '
|
||||
u'title="Permalink to this code">\xb6</a></div>')
|
||||
assert caption in html
|
||||
|
||||
@@ -66,9 +66,9 @@ def test_code_block_caption_latex(app, status, warning):
|
||||
app.builder.build_all()
|
||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:caption-test-rb}}'
|
||||
link = '\hyperref[caption:caption-test-rb]' \
|
||||
'{Listing \\ref{caption:caption-test-rb}}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:id1}}'
|
||||
link = '\hyperref[caption:name-test-rb]' \
|
||||
'{Listing \\ref{caption:name-test-rb}}'
|
||||
assert caption in latex
|
||||
assert label in latex
|
||||
assert link in latex
|
||||
@@ -244,7 +244,7 @@ def test_literalinclude_caption_html(app, status, warning):
|
||||
caption = (u'<div class="code-block-caption">'
|
||||
u'<span class="caption-number">Listing 2 </span>'
|
||||
u'<span class="caption-text">caption <strong>test</strong> py'
|
||||
u'</span><a class="headerlink" href="#caption-test-py" '
|
||||
u'</span><a class="headerlink" href="#id2" '
|
||||
u'title="Permalink to this code">\xb6</a></div>')
|
||||
assert caption in html
|
||||
|
||||
@@ -254,9 +254,9 @@ def test_literalinclude_caption_latex(app, status, warning):
|
||||
app.builder.build('index')
|
||||
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
|
||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:caption-test-py}}'
|
||||
link = '\hyperref[caption:caption-test-py]' \
|
||||
'{Listing \\ref{caption:caption-test-py}}'
|
||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{caption:id2}}'
|
||||
link = '\hyperref[caption:name-test-py]' \
|
||||
'{Listing \\ref{caption:name-test-py}}'
|
||||
assert caption in latex
|
||||
assert label in latex
|
||||
assert link in latex
|
||||
|
||||
Reference in New Issue
Block a user