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 %>}
|
||||
\newcommand{\sphinxlogo}{<%= logo %>}
|
||||
<%- if releasename or release %>
|
||||
\renewcommand{\releasename}{<%= releasename or _('Release') %>}
|
||||
\renewcommand{\releasename}{<%= releasename or _('Release') | e %>}
|
||||
<%- else %>
|
||||
\renewcommand{\releasename}{}
|
||||
<%- endif %>
|
||||
@ -63,6 +63,6 @@
|
||||
<%= body %>
|
||||
<%= atendofbody %>
|
||||
<%= indices %>
|
||||
\renewcommand{\indexname}{<%= _('Index') %>}
|
||||
\renewcommand{\indexname}{<%= _('Index') | e %>}
|
||||
<%= printindex %>
|
||||
\end{document}
|
||||
|
@ -16,6 +16,7 @@ from jinja2.sandbox import SandboxedEnvironment
|
||||
from sphinx import package_dir
|
||||
from sphinx.jinja2glue import SphinxFileSystemLoader
|
||||
from sphinx.locale import get_translator
|
||||
from sphinx.util import texescape
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
@ -72,6 +73,10 @@ class LaTeXRenderer(SphinxRenderer):
|
||||
template_path = os.path.join(package_dir, 'templates', 'latex')
|
||||
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
|
||||
# tagging of jinja2 is not good for LaTeX sources.
|
||||
self.env.variable_start_string = '<%='
|
||||
|
@ -11,6 +11,10 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Dict # NOQA
|
||||
|
||||
tex_replacements = [
|
||||
# map TeX special chars
|
||||
('$', r'\$'),
|
||||
@ -117,11 +121,16 @@ tex_replacements = [
|
||||
('Ω', r'\(\Omega\)'),
|
||||
]
|
||||
|
||||
tex_escape_map = {}
|
||||
tex_escape_map = {} # type: Dict[int, unicode]
|
||||
tex_replace_map = {}
|
||||
tex_hl_escape_map_new = {}
|
||||
|
||||
|
||||
def escape(s):
|
||||
# type: (unicode) -> unicode
|
||||
return s.translate(tex_escape_map)
|
||||
|
||||
|
||||
def init():
|
||||
# type: () -> None
|
||||
for a, b in tex_replacements:
|
||||
|
Loading…
Reference in New Issue
Block a user