mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
replace ur'' prefix with r'' to support py2/py3 in one source. refs #1350
This commit is contained in:
parent
1e58062692
commit
6ae3b68859
@ -10,6 +10,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from os import path, walk
|
from os import path, walk
|
||||||
from codecs import open
|
from codecs import open
|
||||||
@ -27,7 +28,7 @@ from sphinx.util.osutil import safe_relpath, ensuredir, find_catalog, SEP
|
|||||||
from sphinx.util.console import darkgreen, purple, bold
|
from sphinx.util.console import darkgreen, purple, bold
|
||||||
from sphinx.locale import pairindextypes
|
from sphinx.locale import pairindextypes
|
||||||
|
|
||||||
POHEADER = ur"""
|
POHEADER = r"""
|
||||||
# SOME DESCRIPTIVE TITLE.
|
# SOME DESCRIPTIVE TITLE.
|
||||||
# Copyright (C) %(copyright)s
|
# Copyright (C) %(copyright)s
|
||||||
# This file is distributed under the same license as the %(project)s package.
|
# This file is distributed under the same license as the %(project)s package.
|
||||||
@ -204,19 +205,19 @@ class MessageCatalogBuilder(I18nBuilder):
|
|||||||
|
|
||||||
if self.config.gettext_location:
|
if self.config.gettext_location:
|
||||||
# generate "#: file1:line1\n#: file2:line2 ..."
|
# generate "#: file1:line1\n#: file2:line2 ..."
|
||||||
pofile.write(u"#: %s\n" % "\n#: ".join("%s:%s" %
|
pofile.write("#: %s\n" % "\n#: ".join("%s:%s" %
|
||||||
(safe_relpath(source, self.outdir), line)
|
(safe_relpath(source, self.outdir), line)
|
||||||
for source, line, _ in positions))
|
for source, line, _ in positions))
|
||||||
if self.config.gettext_uuid:
|
if self.config.gettext_uuid:
|
||||||
# generate "# uuid1\n# uuid2\n ..."
|
# generate "# uuid1\n# uuid2\n ..."
|
||||||
pofile.write(u"# %s\n" % "\n# ".join(
|
pofile.write("# %s\n" % "\n# ".join(
|
||||||
uid for _, _, uid in positions))
|
uid for _, _, uid in positions))
|
||||||
|
|
||||||
# message contains *one* line of text ready for translation
|
# message contains *one* line of text ready for translation
|
||||||
message = message.replace(u'\\', ur'\\'). \
|
message = message.replace('\\', r'\\'). \
|
||||||
replace(u'"', ur'\"'). \
|
replace('"', r'\"'). \
|
||||||
replace(u'\n', u'\\n"\n"')
|
replace('\n', '\\n"\n"')
|
||||||
pofile.write(u'msgid "%s"\nmsgstr ""\n\n' % message)
|
pofile.write('msgid "%s"\nmsgstr ""\n\n' % message)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
pofile.close()
|
pofile.close()
|
||||||
|
@ -9,93 +9,95 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
tex_replacements = [
|
tex_replacements = [
|
||||||
# map TeX special chars
|
# map TeX special chars
|
||||||
(u'$', ur'\$'),
|
('$', r'\$'),
|
||||||
(u'%', ur'\%'),
|
('%', r'\%'),
|
||||||
(u'&', ur'\&'),
|
('&', r'\&'),
|
||||||
(u'#', ur'\#'),
|
('#', r'\#'),
|
||||||
(u'_', ur'\_'),
|
('_', r'\_'),
|
||||||
(u'{', ur'\{'),
|
('{', r'\{'),
|
||||||
(u'}', ur'\}'),
|
('}', r'\}'),
|
||||||
(u'[', ur'{[}'),
|
('[', r'{[}'),
|
||||||
(u']', ur'{]}'),
|
(']', r'{]}'),
|
||||||
(u'`', ur'{}`'),
|
('`', r'{}`'),
|
||||||
(u'\\',ur'\textbackslash{}'),
|
('\\',r'\textbackslash{}'),
|
||||||
(u'~', ur'\textasciitilde{}'),
|
('~', r'\textasciitilde{}'),
|
||||||
(u'<', ur'\textless{}'),
|
('<', r'\textless{}'),
|
||||||
(u'>', ur'\textgreater{}'),
|
('>', r'\textgreater{}'),
|
||||||
(u'^', ur'\textasciicircum{}'),
|
('^', r'\textasciicircum{}'),
|
||||||
# map special Unicode characters to TeX commands
|
# map special Unicode characters to TeX commands
|
||||||
(u'¶', ur'\P{}'),
|
('¶', r'\P{}'),
|
||||||
(u'§', ur'\S{}'),
|
('§', r'\S{}'),
|
||||||
(u'€', ur'\texteuro{}'),
|
('€', r'\texteuro{}'),
|
||||||
(u'∞', ur'\(\infty\)'),
|
('∞', r'\(\infty\)'),
|
||||||
(u'±', ur'\(\pm\)'),
|
('±', r'\(\pm\)'),
|
||||||
(u'→', ur'\(\rightarrow\)'),
|
('→', r'\(\rightarrow\)'),
|
||||||
(u'‣', ur'\(\rightarrow\)'),
|
('‣', r'\(\rightarrow\)'),
|
||||||
# used to separate -- in options
|
# used to separate -- in options
|
||||||
(u'', ur'{}'),
|
('', r'{}'),
|
||||||
# map some special Unicode characters to similar ASCII ones
|
# map some special Unicode characters to similar ASCII ones
|
||||||
(u'─', ur'-'),
|
('─', r'-'),
|
||||||
(u'⎽', ur'\_'),
|
('⎽', r'\_'),
|
||||||
(u'╲', ur'\textbackslash{}'),
|
('╲', r'\textbackslash{}'),
|
||||||
(u'|', ur'\textbar{}'),
|
('|', r'\textbar{}'),
|
||||||
(u'│', ur'\textbar{}'),
|
('│', r'\textbar{}'),
|
||||||
(u'ℯ', ur'e'),
|
('ℯ', r'e'),
|
||||||
(u'ⅈ', ur'i'),
|
('ⅈ', r'i'),
|
||||||
(u'₁', ur'1'),
|
('₁', r'1'),
|
||||||
(u'₂', ur'2'),
|
('₂', r'2'),
|
||||||
# map Greek alphabet
|
# map Greek alphabet
|
||||||
(u'α', ur'\(\alpha\)'),
|
('α', r'\(\alpha\)'),
|
||||||
(u'β', ur'\(\beta\)'),
|
('β', r'\(\beta\)'),
|
||||||
(u'γ', ur'\(\gamma\)'),
|
('γ', r'\(\gamma\)'),
|
||||||
(u'δ', ur'\(\delta\)'),
|
('δ', r'\(\delta\)'),
|
||||||
(u'ε', ur'\(\epsilon\)'),
|
('ε', r'\(\epsilon\)'),
|
||||||
(u'ζ', ur'\(\zeta\)'),
|
('ζ', r'\(\zeta\)'),
|
||||||
(u'η', ur'\(\eta\)'),
|
('η', r'\(\eta\)'),
|
||||||
(u'θ', ur'\(\theta\)'),
|
('θ', r'\(\theta\)'),
|
||||||
(u'ι', ur'\(\iota\)'),
|
('ι', r'\(\iota\)'),
|
||||||
(u'κ', ur'\(\kappa\)'),
|
('κ', r'\(\kappa\)'),
|
||||||
(u'λ', ur'\(\lambda\)'),
|
('λ', r'\(\lambda\)'),
|
||||||
(u'μ', ur'\(\mu\)'),
|
('μ', r'\(\mu\)'),
|
||||||
(u'ν', ur'\(\nu\)'),
|
('ν', r'\(\nu\)'),
|
||||||
(u'ξ', ur'\(\xi\)'),
|
('ξ', r'\(\xi\)'),
|
||||||
(u'ο', ur'o'),
|
('ο', r'o'),
|
||||||
(u'π', ur'\(\pi\)'),
|
('π', r'\(\pi\)'),
|
||||||
(u'ρ', ur'\(\rho\)'),
|
('ρ', r'\(\rho\)'),
|
||||||
(u'σ', ur'\(\sigma\)'),
|
('σ', r'\(\sigma\)'),
|
||||||
(u'τ', ur'\(\tau\)'),
|
('τ', r'\(\tau\)'),
|
||||||
(u'υ', u'\\(\\upsilon\\)'),
|
('υ', '\\(\\upsilon\\)'),
|
||||||
(u'φ', ur'\(\phi\)'),
|
('φ', r'\(\phi\)'),
|
||||||
(u'χ', ur'\(\chi\)'),
|
('χ', r'\(\chi\)'),
|
||||||
(u'ψ', ur'\(\psi\)'),
|
('ψ', r'\(\psi\)'),
|
||||||
(u'ω', ur'\(\omega\)'),
|
('ω', r'\(\omega\)'),
|
||||||
(u'Α', ur'A'),
|
('Α', r'A'),
|
||||||
(u'Β', ur'B'),
|
('Β', r'B'),
|
||||||
(u'Γ', ur'\(\Gamma\)'),
|
('Γ', r'\(\Gamma\)'),
|
||||||
(u'Δ', ur'\(\Delta\)'),
|
('Δ', r'\(\Delta\)'),
|
||||||
(u'Ε', ur'E'),
|
('Ε', r'E'),
|
||||||
(u'Ζ', ur'Z'),
|
('Ζ', r'Z'),
|
||||||
(u'Η', ur'H'),
|
('Η', r'H'),
|
||||||
(u'Θ', ur'\(\Theta\)'),
|
('Θ', r'\(\Theta\)'),
|
||||||
(u'Ι', ur'I'),
|
('Ι', r'I'),
|
||||||
(u'Κ', ur'K'),
|
('Κ', r'K'),
|
||||||
(u'Λ', ur'\(\Lambda\)'),
|
('Λ', r'\(\Lambda\)'),
|
||||||
(u'Μ', ur'M'),
|
('Μ', r'M'),
|
||||||
(u'Ν', ur'N'),
|
('Ν', r'N'),
|
||||||
(u'Ξ', ur'\(\Xi\)'),
|
('Ξ', r'\(\Xi\)'),
|
||||||
(u'Ο', ur'O'),
|
('Ο', r'O'),
|
||||||
(u'Π', ur'\(\Pi\)'),
|
('Π', r'\(\Pi\)'),
|
||||||
(u'Ρ', ur'P'),
|
('Ρ', r'P'),
|
||||||
(u'Σ', ur'\(\Sigma\)'),
|
('Σ', r'\(\Sigma\)'),
|
||||||
(u'Τ', ur'T'),
|
('Τ', r'T'),
|
||||||
(u'Υ', u'\\(\\Upsilon\\)'),
|
('Υ', '\\(\\Upsilon\\)'),
|
||||||
(u'Φ', ur'\(\Phi\)'),
|
('Φ', r'\(\Phi\)'),
|
||||||
(u'Χ', ur'X'),
|
('Χ', r'X'),
|
||||||
(u'Ψ', ur'\(\Psi\)'),
|
('Ψ', r'\(\Psi\)'),
|
||||||
(u'Ω', ur'\(\Omega\)'),
|
('Ω', r'\(\Omega\)'),
|
||||||
(u'Ω', ur'\(\Omega\)'),
|
('Ω', r'\(\Omega\)'),
|
||||||
]
|
]
|
||||||
|
|
||||||
tex_escape_map = {}
|
tex_escape_map = {}
|
||||||
@ -105,8 +107,8 @@ tex_hl_escape_map_new = {}
|
|||||||
def init():
|
def init():
|
||||||
for a, b in tex_replacements:
|
for a, b in tex_replacements:
|
||||||
tex_escape_map[ord(a)] = b
|
tex_escape_map[ord(a)] = b
|
||||||
tex_replace_map[ord(a)] = u'_'
|
tex_replace_map[ord(a)] = '_'
|
||||||
|
|
||||||
for a, b in tex_replacements:
|
for a, b in tex_replacements:
|
||||||
if a in u'[]{}\\': continue
|
if a in '[]{}\\': continue
|
||||||
tex_hl_escape_map_new[ord(a)] = b
|
tex_hl_escape_map_new[ord(a)] = b
|
||||||
|
@ -711,7 +711,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append('\n\\hline\n')
|
self.body.append('\n\\hline\n')
|
||||||
self.body.extend(self.tableheaders)
|
self.body.extend(self.tableheaders)
|
||||||
self.body.append('\\endhead\n\n')
|
self.body.append('\\endhead\n\n')
|
||||||
self.body.append(ur'\hline \multicolumn{%s}{|r|}{{\textsf{%s}}} \\ \hline'
|
self.body.append(r'\hline \multicolumn{%s}{|r|}{{\textsf{%s}}} \\ \hline'
|
||||||
% (self.table.colcount,
|
% (self.table.colcount,
|
||||||
_('Continued on next page')))
|
_('Continued on next page')))
|
||||||
self.body.append('\n\\endfoot\n\n')
|
self.body.append('\n\\endfoot\n\n')
|
||||||
|
@ -266,7 +266,7 @@ if pygments:
|
|||||||
(".//div[@class='inc-lines highlight-text']//pre",
|
(".//div[@class='inc-lines highlight-text']//pre",
|
||||||
r'^class Foo:\n pass\nclass Bar:\n$'),
|
r'^class Foo:\n pass\nclass Bar:\n$'),
|
||||||
(".//div[@class='inc-startend highlight-text']//pre",
|
(".//div[@class='inc-startend highlight-text']//pre",
|
||||||
ur'^foo = "Including Unicode characters: üöä"\n$'),
|
u'^foo = "Including Unicode characters: üöä"\\n$'),
|
||||||
(".//div[@class='inc-preappend highlight-text']//pre",
|
(".//div[@class='inc-preappend highlight-text']//pre",
|
||||||
r'(?m)^START CODE$'),
|
r'(?m)^START CODE$'),
|
||||||
(".//div[@class='inc-pyobj-dedent highlight-python']//span",
|
(".//div[@class='inc-pyobj-dedent highlight-python']//span",
|
||||||
|
@ -128,7 +128,7 @@ def test_inline():
|
|||||||
def test_latex_escaping():
|
def test_latex_escaping():
|
||||||
# correct escaping in normal mode
|
# correct escaping in normal mode
|
||||||
yield (verify, u'Γ\\\\∞$', None,
|
yield (verify, u'Γ\\\\∞$', None,
|
||||||
ur'\(\Gamma\)\textbackslash{}\(\infty\)\$')
|
r'\(\Gamma\)\textbackslash{}\(\infty\)\$')
|
||||||
# in verbatim code fragments
|
# in verbatim code fragments
|
||||||
yield (verify, u'::\n\n @Γ\\∞${}', None,
|
yield (verify, u'::\n\n @Γ\\∞${}', None,
|
||||||
u'\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n'
|
u'\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n'
|
||||||
@ -136,4 +136,4 @@ def test_latex_escaping():
|
|||||||
u'\\end{Verbatim}')
|
u'\\end{Verbatim}')
|
||||||
# in URIs
|
# in URIs
|
||||||
yield (verify_re, u'`test <http://example.com/~me/>`_', None,
|
yield (verify_re, u'`test <http://example.com/~me/>`_', None,
|
||||||
ur'\\href{http://example.com/~me/}{test}.*')
|
r'\\href{http://example.com/~me/}{test}.*')
|
||||||
|
Loading…
Reference in New Issue
Block a user