mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: Move \literalblockname to sphinxmessage.sty
This commit is contained in:
parent
ebd484ead2
commit
cd28de5ba8
@ -419,10 +419,12 @@ class LaTeXBuilder(Builder):
|
||||
|
||||
def write_message_catalog(self):
|
||||
# type: () -> None
|
||||
formats = self.config.numfig_format
|
||||
context = {
|
||||
'addtocaptions': '',
|
||||
'figurename': self.config.numfig_format.get('figure', '').split('%s', 1),
|
||||
'tablename': self.config.numfig_format.get('table', '').split('%s', 1)
|
||||
'figurename': formats.get('figure', '').split('%s', 1),
|
||||
'tablename': formats.get('table', '').split('%s', 1),
|
||||
'literalblockname': formats.get('code-block', '').split('%s', 1)
|
||||
}
|
||||
|
||||
if self.context['babel'] or self.context['polyglossia']:
|
||||
|
@ -21,3 +21,5 @@
|
||||
<%- if tablename[1] %>
|
||||
\def\fnum@table{\tablename\thetable\relax{}<%= tablename[1].strip() | e %>}
|
||||
<%- endif %>
|
||||
|
||||
<%= addtocaptions %>{\renewcommand{\literalblockname}{<%= literalblockname[0].strip() %>}}
|
||||
|
@ -203,7 +203,6 @@ def test_numref(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Listing}}' in result
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{Fig.\\@ \\ref{\\detokenize{index:fig1}}}') in result
|
||||
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
||||
@ -230,6 +229,7 @@ def test_numref(app, status, warning):
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Listing}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -245,7 +245,6 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
|
||||
assert '\\ref{\\detokenize{index:fig1}}' in result
|
||||
assert '\\ref{\\detokenize{baz:fig22}}' in result
|
||||
assert '\\ref{\\detokenize{index:table-1}}' in result
|
||||
@ -278,6 +277,7 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab_}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Code-}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -293,7 +293,6 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\addto\\captionsenglish{\\renewcommand{\\literalblockname}{Code-}}' in result
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{Figure:\\ref{\\detokenize{index:fig1}}.\\@}') in result
|
||||
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
||||
@ -322,6 +321,7 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
assert r'\def\fnum@figure{\figurename\thefigure\relax{}.}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab_}}' in result
|
||||
assert r'\def\fnum@table{\tablename\thetable\relax{}:}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Code-}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -333,7 +333,6 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert '\\renewcommand{\\literalblockname}{\u30ea\u30b9\u30c8}' in result # リスト
|
||||
assert ('\\hyperref[\\detokenize{index:fig1}]'
|
||||
'{\u56f3 \\ref{\\detokenize{index:fig1}}}') in result
|
||||
assert ('\\hyperref[\\detokenize{baz:fig22}]'
|
||||
@ -360,6 +359,7 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
print(result)
|
||||
assert '\n{\\renewcommand{\\figurename}{図}}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{表}}' in result
|
||||
assert '\n{\\renewcommand{\\literalblockname}{リスト}}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-numfig')
|
||||
|
Loading…
Reference in New Issue
Block a user