mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
latex: escape \releasename and \indexname
This commit is contained in:
parent
6eb5b29484
commit
75fdf1363e
@ -48,7 +48,7 @@
|
|||||||
\author{<%= author %>}
|
\author{<%= author %>}
|
||||||
\newcommand{\sphinxlogo}{<%= logo %>}
|
\newcommand{\sphinxlogo}{<%= logo %>}
|
||||||
<%- if releasename or release %>
|
<%- if releasename or release %>
|
||||||
\renewcommand{\releasename}{<%= releasename or _('Release') %>}
|
\renewcommand{\releasename}{<%= releasename or _('Release') | e %>}
|
||||||
<%- else %>
|
<%- else %>
|
||||||
\renewcommand{\releasename}{}
|
\renewcommand{\releasename}{}
|
||||||
<%- endif %>
|
<%- endif %>
|
||||||
@ -63,6 +63,6 @@
|
|||||||
<%= body %>
|
<%= body %>
|
||||||
<%= atendofbody %>
|
<%= atendofbody %>
|
||||||
<%= indices %>
|
<%= indices %>
|
||||||
\renewcommand{\indexname}{<%= _('Index') %>}
|
\renewcommand{\indexname}{<%= _('Index') | e %>}
|
||||||
<%= printindex %>
|
<%= printindex %>
|
||||||
\end{document}
|
\end{document}
|
||||||
|
@ -16,6 +16,7 @@ from jinja2.sandbox import SandboxedEnvironment
|
|||||||
from sphinx import package_dir
|
from sphinx import package_dir
|
||||||
from sphinx.jinja2glue import SphinxFileSystemLoader
|
from sphinx.jinja2glue import SphinxFileSystemLoader
|
||||||
from sphinx.locale import get_translator
|
from sphinx.locale import get_translator
|
||||||
|
from sphinx.util import texescape
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@ -72,6 +73,10 @@ class LaTeXRenderer(SphinxRenderer):
|
|||||||
template_path = os.path.join(package_dir, 'templates', 'latex')
|
template_path = os.path.join(package_dir, 'templates', 'latex')
|
||||||
super(LaTeXRenderer, self).__init__(template_path)
|
super(LaTeXRenderer, self).__init__(template_path)
|
||||||
|
|
||||||
|
# use texescape as escape filter
|
||||||
|
self.env.filters['e'] = texescape.escape
|
||||||
|
self.env.filters['escape'] = texescape.escape
|
||||||
|
|
||||||
# use JSP/eRuby like tagging instead because curly bracket; the default
|
# use JSP/eRuby like tagging instead because curly bracket; the default
|
||||||
# tagging of jinja2 is not good for LaTeX sources.
|
# tagging of jinja2 is not good for LaTeX sources.
|
||||||
self.env.variable_start_string = '<%='
|
self.env.variable_start_string = '<%='
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
if False:
|
||||||
|
# For type annotation
|
||||||
|
from typing import Dict # NOQA
|
||||||
|
|
||||||
tex_replacements = [
|
tex_replacements = [
|
||||||
# map TeX special chars
|
# map TeX special chars
|
||||||
('$', r'\$'),
|
('$', r'\$'),
|
||||||
@ -117,11 +121,16 @@ tex_replacements = [
|
|||||||
('Ω', r'\(\Omega\)'),
|
('Ω', r'\(\Omega\)'),
|
||||||
]
|
]
|
||||||
|
|
||||||
tex_escape_map = {}
|
tex_escape_map = {} # type: Dict[int, unicode]
|
||||||
tex_replace_map = {}
|
tex_replace_map = {}
|
||||||
tex_hl_escape_map_new = {}
|
tex_hl_escape_map_new = {}
|
||||||
|
|
||||||
|
|
||||||
|
def escape(s):
|
||||||
|
# type: (unicode) -> unicode
|
||||||
|
return s.translate(tex_escape_map)
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
for a, b in tex_replacements:
|
for a, b in tex_replacements:
|
||||||
|
Loading…
Reference in New Issue
Block a user