mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '1.8'
Conflicts: sphinx/writers/latex.py tests/test_build_latex.py Also, modifications were needed in further files. modified: CHANGES modified: sphinx/templates/latex/sphinxmessages.sty_t modified: sphinx/util/template.py modified: sphinx/util/texescape.py modified: sphinx/writers/latex.py modified: tests/test_build_latex.py
This commit is contained in:
commit
af2bb9f80d
3
CHANGES
3
CHANGES
@ -181,8 +181,11 @@ Features added
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
* #3707: latex: no bold checkmark (✔) available.
|
||||
* #5605: with the documentation language set to Chinese, English words could not
|
||||
be searched.
|
||||
* #5889: LaTeX: user ``numfig_format`` is stripped of spaces and may cause
|
||||
build failure
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -12,14 +12,10 @@
|
||||
\renewcommand{\sphinxnumbersname}{<%= _('Numbers') | e %>}
|
||||
\def\pageautorefname{<%= _('page') | e %>}
|
||||
|
||||
<%= addtocaptions %>{\renewcommand{\figurename}{<%= figurename[0].strip() | e %>}}
|
||||
<%- if figurename[1] %>
|
||||
\def\fnum@figure{\figurename\thefigure\relax{}<%= figurename[1].strip() | e %>}
|
||||
<%- endif %>
|
||||
<%= addtocaptions %>{\renewcommand{\figurename}{<%= figurename[0] | e | eabbr %>}}
|
||||
\def\fnum@figure{\figurename\thefigure{}<%= figurename[1] | e %>}
|
||||
|
||||
<%= addtocaptions %>{\renewcommand{\tablename}{<%= tablename[0].strip() %>}}
|
||||
<%- if tablename[1] %>
|
||||
\def\fnum@table{\tablename\thetable\relax{}<%= tablename[1].strip() | e %>}
|
||||
<%- endif %>
|
||||
<%= addtocaptions %>{\renewcommand{\tablename}{<%= tablename[0] | e | eabbr %>}}
|
||||
\def\fnum@table{\tablename\thetable{}<%= tablename[1] | e %>}
|
||||
|
||||
<%= addtocaptions %>{\renewcommand{\literalblockname}{<%= literalblockname[0].strip() %>}}
|
||||
|
@ -75,6 +75,7 @@ class LaTeXRenderer(SphinxRenderer):
|
||||
# use texescape as escape filter
|
||||
self.env.filters['e'] = texescape.escape
|
||||
self.env.filters['escape'] = texescape.escape
|
||||
self.env.filters['eabbr'] = texescape.escape_abbr
|
||||
|
||||
# use JSP/eRuby like tagging instead because curly bracket; the default
|
||||
# tagging of jinja2 is not good for LaTeX sources.
|
||||
|
@ -8,6 +8,8 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict # NOQA
|
||||
@ -38,6 +40,7 @@ tex_replacements = [
|
||||
('→', r'\(\rightarrow\)'),
|
||||
('‣', r'\(\rightarrow\)'),
|
||||
('✓', r'\(\checkmark\)'),
|
||||
('✔', r'\(\pmb{\checkmark}\)'),
|
||||
# used to separate -- in options
|
||||
('', r'{}'),
|
||||
# map some special Unicode characters to similar ASCII ones
|
||||
@ -81,6 +84,12 @@ def escape(s):
|
||||
return s.translate(tex_escape_map)
|
||||
|
||||
|
||||
def escape_abbr(text):
|
||||
# type: (str) -> str
|
||||
"""Adjust spacing after abbreviations. Works with @ letter or other."""
|
||||
return re.sub(r'\.(?=\s|$)', r'.\@{}', text)
|
||||
|
||||
|
||||
def init():
|
||||
# type: () -> None
|
||||
for a, b in tex_replacements:
|
||||
|
@ -2571,26 +2571,24 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
ret.append('\\def\\fnum@figure{%s}\n' %
|
||||
str(figure[0]).strip().translate(tex_escape_map))
|
||||
else:
|
||||
definition = str(figure[0]).strip().translate(tex_escape_map)
|
||||
definition = escape_abbr(str(figure[0]).translate(tex_escape_map))
|
||||
ret.append(self.babel_renewcommand('\\figurename', definition))
|
||||
if figure[1]:
|
||||
ret.append('\\makeatletter\n')
|
||||
ret.append('\\def\\fnum@figure{\\figurename\\thefigure%s}\n' %
|
||||
str(figure[1]).strip().translate(tex_escape_map))
|
||||
ret.append('\\makeatother\n')
|
||||
ret.append('\\makeatletter\n')
|
||||
ret.append('\\def\\fnum@figure{\\figurename\\thefigure{}%s}\n' %
|
||||
str(figure[1]).translate(tex_escape_map))
|
||||
ret.append('\\makeatother\n')
|
||||
|
||||
table = self.builder.config.numfig_format['table'].split('%s', 1)
|
||||
if len(table) == 1:
|
||||
ret.append('\\def\\fnum@table{%s}\n' %
|
||||
str(table[0]).strip().translate(tex_escape_map))
|
||||
else:
|
||||
definition = str(table[0]).strip().translate(tex_escape_map)
|
||||
definition = escape_abbr(str(table[0]).translate(tex_escape_map))
|
||||
ret.append(self.babel_renewcommand('\\tablename', definition))
|
||||
if table[1]:
|
||||
ret.append('\\makeatletter\n')
|
||||
ret.append('\\def\\fnum@table{\\tablename\\thetable%s}\n' %
|
||||
str(table[1]).strip().translate(tex_escape_map))
|
||||
ret.append('\\makeatother\n')
|
||||
ret.append('\\makeatletter\n')
|
||||
ret.append('\\def\\fnum@table{\\tablename\\thetable{}%s}\n' %
|
||||
str(table[1]).translate(tex_escape_map))
|
||||
ret.append('\\makeatother\n')
|
||||
|
||||
codeblock = self.builder.config.numfig_format['code-block'].split('%s', 1)
|
||||
if len(codeblock) == 1:
|
||||
|
@ -227,8 +227,8 @@ def test_numref(app, status, warning):
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
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{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table }}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Listing}}' in result
|
||||
|
||||
|
||||
@ -276,7 +276,7 @@ def test_numref_with_prefix1(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
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{\tablename}{Tab\_}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Code-}}' in result
|
||||
|
||||
|
||||
@ -318,9 +318,9 @@ def test_numref_with_prefix2(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Figure:}}' in result
|
||||
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'\def\fnum@figure{\figurename\thefigure{}.}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Tab\_}}' in result
|
||||
assert r'\def\fnum@table{\tablename\thetable{}:}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\literalblockname}{Code-}}' in result
|
||||
|
||||
|
||||
@ -357,8 +357,8 @@ def test_numref_with_language_ja(app, status, warning):
|
||||
# sphinxmessages.sty
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert '\n{\\renewcommand{\\figurename}{図}}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{表}}' in result
|
||||
assert '\n{\\renewcommand{\\figurename}{図 }}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{表 }}' in result
|
||||
assert '\n{\\renewcommand{\\literalblockname}{リスト}}' in result
|
||||
|
||||
|
||||
@ -441,8 +441,8 @@ def test_babel_with_no_language_settings(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -466,8 +466,8 @@ def test_babel_with_language_de(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{Seite}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsngerman{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -491,8 +491,8 @@ def test_babel_with_language_ru(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{страница}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsrussian{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -516,8 +516,8 @@ def test_babel_with_language_tr(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{sayfa}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsturkish{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -540,8 +540,8 @@ def test_babel_with_language_ja(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{ページ}' in result
|
||||
assert '\n{\\renewcommand{\\figurename}{Fig.}}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{Table.}}' in result
|
||||
assert '\n{\\renewcommand{\\figurename}{Fig.\\@{} }}' in result
|
||||
assert '\n{\\renewcommand{\\tablename}{Table.\\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -567,8 +567,8 @@ def test_babel_with_unknown_language(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsenglish{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -593,8 +593,8 @@ def test_polyglossia_with_language_de(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{Seite}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@ -619,8 +619,8 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
||||
result = (app.outdir / 'sphinxmessages.sty').text(encoding='utf8')
|
||||
print(result)
|
||||
assert r'\def\pageautorefname{page}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.}}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.}}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\figurename}{Fig.\@{} }}' in result
|
||||
assert r'\addto\captionsgerman{\renewcommand{\tablename}{Table.\@{} }}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex')
|
||||
|
Loading…
Reference in New Issue
Block a user