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 unicode_literals
|
||||
|
||||
from os import path, walk
|
||||
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.locale import pairindextypes
|
||||
|
||||
POHEADER = ur"""
|
||||
POHEADER = r"""
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) %(copyright)s
|
||||
# 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:
|
||||
# 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)
|
||||
for source, line, _ in positions))
|
||||
if self.config.gettext_uuid:
|
||||
# generate "# uuid1\n# uuid2\n ..."
|
||||
pofile.write(u"# %s\n" % "\n# ".join(
|
||||
pofile.write("# %s\n" % "\n# ".join(
|
||||
uid for _, _, uid in positions))
|
||||
|
||||
# message contains *one* line of text ready for translation
|
||||
message = message.replace(u'\\', ur'\\'). \
|
||||
replace(u'"', ur'\"'). \
|
||||
replace(u'\n', u'\\n"\n"')
|
||||
pofile.write(u'msgid "%s"\nmsgstr ""\n\n' % message)
|
||||
message = message.replace('\\', r'\\'). \
|
||||
replace('"', r'\"'). \
|
||||
replace('\n', '\\n"\n"')
|
||||
pofile.write('msgid "%s"\nmsgstr ""\n\n' % message)
|
||||
|
||||
finally:
|
||||
pofile.close()
|
||||
|
@ -9,93 +9,95 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
tex_replacements = [
|
||||
# map TeX special chars
|
||||
(u'$', ur'\$'),
|
||||
(u'%', ur'\%'),
|
||||
(u'&', ur'\&'),
|
||||
(u'#', ur'\#'),
|
||||
(u'_', ur'\_'),
|
||||
(u'{', ur'\{'),
|
||||
(u'}', ur'\}'),
|
||||
(u'[', ur'{[}'),
|
||||
(u']', ur'{]}'),
|
||||
(u'`', ur'{}`'),
|
||||
(u'\\',ur'\textbackslash{}'),
|
||||
(u'~', ur'\textasciitilde{}'),
|
||||
(u'<', ur'\textless{}'),
|
||||
(u'>', ur'\textgreater{}'),
|
||||
(u'^', ur'\textasciicircum{}'),
|
||||
('$', r'\$'),
|
||||
('%', r'\%'),
|
||||
('&', r'\&'),
|
||||
('#', r'\#'),
|
||||
('_', r'\_'),
|
||||
('{', r'\{'),
|
||||
('}', r'\}'),
|
||||
('[', r'{[}'),
|
||||
(']', r'{]}'),
|
||||
('`', r'{}`'),
|
||||
('\\',r'\textbackslash{}'),
|
||||
('~', r'\textasciitilde{}'),
|
||||
('<', r'\textless{}'),
|
||||
('>', r'\textgreater{}'),
|
||||
('^', r'\textasciicircum{}'),
|
||||
# map special Unicode characters to TeX commands
|
||||
(u'¶', ur'\P{}'),
|
||||
(u'§', ur'\S{}'),
|
||||
(u'€', ur'\texteuro{}'),
|
||||
(u'∞', ur'\(\infty\)'),
|
||||
(u'±', ur'\(\pm\)'),
|
||||
(u'→', ur'\(\rightarrow\)'),
|
||||
(u'‣', ur'\(\rightarrow\)'),
|
||||
('¶', r'\P{}'),
|
||||
('§', r'\S{}'),
|
||||
('€', r'\texteuro{}'),
|
||||
('∞', r'\(\infty\)'),
|
||||
('±', r'\(\pm\)'),
|
||||
('→', r'\(\rightarrow\)'),
|
||||
('‣', r'\(\rightarrow\)'),
|
||||
# used to separate -- in options
|
||||
(u'', ur'{}'),
|
||||
('', r'{}'),
|
||||
# map some special Unicode characters to similar ASCII ones
|
||||
(u'─', ur'-'),
|
||||
(u'⎽', ur'\_'),
|
||||
(u'╲', ur'\textbackslash{}'),
|
||||
(u'|', ur'\textbar{}'),
|
||||
(u'│', ur'\textbar{}'),
|
||||
(u'ℯ', ur'e'),
|
||||
(u'ⅈ', ur'i'),
|
||||
(u'₁', ur'1'),
|
||||
(u'₂', ur'2'),
|
||||
('─', r'-'),
|
||||
('⎽', r'\_'),
|
||||
('╲', r'\textbackslash{}'),
|
||||
('|', r'\textbar{}'),
|
||||
('│', r'\textbar{}'),
|
||||
('ℯ', r'e'),
|
||||
('ⅈ', r'i'),
|
||||
('₁', r'1'),
|
||||
('₂', r'2'),
|
||||
# map Greek alphabet
|
||||
(u'α', ur'\(\alpha\)'),
|
||||
(u'β', ur'\(\beta\)'),
|
||||
(u'γ', ur'\(\gamma\)'),
|
||||
(u'δ', ur'\(\delta\)'),
|
||||
(u'ε', ur'\(\epsilon\)'),
|
||||
(u'ζ', ur'\(\zeta\)'),
|
||||
(u'η', ur'\(\eta\)'),
|
||||
(u'θ', ur'\(\theta\)'),
|
||||
(u'ι', ur'\(\iota\)'),
|
||||
(u'κ', ur'\(\kappa\)'),
|
||||
(u'λ', ur'\(\lambda\)'),
|
||||
(u'μ', ur'\(\mu\)'),
|
||||
(u'ν', ur'\(\nu\)'),
|
||||
(u'ξ', ur'\(\xi\)'),
|
||||
(u'ο', ur'o'),
|
||||
(u'π', ur'\(\pi\)'),
|
||||
(u'ρ', ur'\(\rho\)'),
|
||||
(u'σ', ur'\(\sigma\)'),
|
||||
(u'τ', ur'\(\tau\)'),
|
||||
(u'υ', u'\\(\\upsilon\\)'),
|
||||
(u'φ', ur'\(\phi\)'),
|
||||
(u'χ', ur'\(\chi\)'),
|
||||
(u'ψ', ur'\(\psi\)'),
|
||||
(u'ω', ur'\(\omega\)'),
|
||||
(u'Α', ur'A'),
|
||||
(u'Β', ur'B'),
|
||||
(u'Γ', ur'\(\Gamma\)'),
|
||||
(u'Δ', ur'\(\Delta\)'),
|
||||
(u'Ε', ur'E'),
|
||||
(u'Ζ', ur'Z'),
|
||||
(u'Η', ur'H'),
|
||||
(u'Θ', ur'\(\Theta\)'),
|
||||
(u'Ι', ur'I'),
|
||||
(u'Κ', ur'K'),
|
||||
(u'Λ', ur'\(\Lambda\)'),
|
||||
(u'Μ', ur'M'),
|
||||
(u'Ν', ur'N'),
|
||||
(u'Ξ', ur'\(\Xi\)'),
|
||||
(u'Ο', ur'O'),
|
||||
(u'Π', ur'\(\Pi\)'),
|
||||
(u'Ρ', ur'P'),
|
||||
(u'Σ', ur'\(\Sigma\)'),
|
||||
(u'Τ', ur'T'),
|
||||
(u'Υ', u'\\(\\Upsilon\\)'),
|
||||
(u'Φ', ur'\(\Phi\)'),
|
||||
(u'Χ', ur'X'),
|
||||
(u'Ψ', ur'\(\Psi\)'),
|
||||
(u'Ω', ur'\(\Omega\)'),
|
||||
(u'Ω', ur'\(\Omega\)'),
|
||||
('α', r'\(\alpha\)'),
|
||||
('β', r'\(\beta\)'),
|
||||
('γ', r'\(\gamma\)'),
|
||||
('δ', r'\(\delta\)'),
|
||||
('ε', r'\(\epsilon\)'),
|
||||
('ζ', r'\(\zeta\)'),
|
||||
('η', r'\(\eta\)'),
|
||||
('θ', r'\(\theta\)'),
|
||||
('ι', r'\(\iota\)'),
|
||||
('κ', r'\(\kappa\)'),
|
||||
('λ', r'\(\lambda\)'),
|
||||
('μ', r'\(\mu\)'),
|
||||
('ν', r'\(\nu\)'),
|
||||
('ξ', r'\(\xi\)'),
|
||||
('ο', r'o'),
|
||||
('π', r'\(\pi\)'),
|
||||
('ρ', r'\(\rho\)'),
|
||||
('σ', r'\(\sigma\)'),
|
||||
('τ', r'\(\tau\)'),
|
||||
('υ', '\\(\\upsilon\\)'),
|
||||
('φ', r'\(\phi\)'),
|
||||
('χ', r'\(\chi\)'),
|
||||
('ψ', r'\(\psi\)'),
|
||||
('ω', r'\(\omega\)'),
|
||||
('Α', r'A'),
|
||||
('Β', r'B'),
|
||||
('Γ', r'\(\Gamma\)'),
|
||||
('Δ', r'\(\Delta\)'),
|
||||
('Ε', r'E'),
|
||||
('Ζ', r'Z'),
|
||||
('Η', r'H'),
|
||||
('Θ', r'\(\Theta\)'),
|
||||
('Ι', r'I'),
|
||||
('Κ', r'K'),
|
||||
('Λ', r'\(\Lambda\)'),
|
||||
('Μ', r'M'),
|
||||
('Ν', r'N'),
|
||||
('Ξ', r'\(\Xi\)'),
|
||||
('Ο', r'O'),
|
||||
('Π', r'\(\Pi\)'),
|
||||
('Ρ', r'P'),
|
||||
('Σ', r'\(\Sigma\)'),
|
||||
('Τ', r'T'),
|
||||
('Υ', '\\(\\Upsilon\\)'),
|
||||
('Φ', r'\(\Phi\)'),
|
||||
('Χ', r'X'),
|
||||
('Ψ', r'\(\Psi\)'),
|
||||
('Ω', r'\(\Omega\)'),
|
||||
('Ω', r'\(\Omega\)'),
|
||||
]
|
||||
|
||||
tex_escape_map = {}
|
||||
@ -105,8 +107,8 @@ tex_hl_escape_map_new = {}
|
||||
def init():
|
||||
for a, b in tex_replacements:
|
||||
tex_escape_map[ord(a)] = b
|
||||
tex_replace_map[ord(a)] = u'_'
|
||||
tex_replace_map[ord(a)] = '_'
|
||||
|
||||
for a, b in tex_replacements:
|
||||
if a in u'[]{}\\': continue
|
||||
if a in '[]{}\\': continue
|
||||
tex_hl_escape_map_new[ord(a)] = b
|
||||
|
@ -711,7 +711,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.body.append('\n\\hline\n')
|
||||
self.body.extend(self.tableheaders)
|
||||
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,
|
||||
_('Continued on next page')))
|
||||
self.body.append('\n\\endfoot\n\n')
|
||||
|
@ -266,7 +266,7 @@ if pygments:
|
||||
(".//div[@class='inc-lines highlight-text']//pre",
|
||||
r'^class Foo:\n pass\nclass Bar:\n$'),
|
||||
(".//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",
|
||||
r'(?m)^START CODE$'),
|
||||
(".//div[@class='inc-pyobj-dedent highlight-python']//span",
|
||||
|
@ -128,7 +128,7 @@ def test_inline():
|
||||
def test_latex_escaping():
|
||||
# correct escaping in normal mode
|
||||
yield (verify, u'Γ\\\\∞$', None,
|
||||
ur'\(\Gamma\)\textbackslash{}\(\infty\)\$')
|
||||
r'\(\Gamma\)\textbackslash{}\(\infty\)\$')
|
||||
# in verbatim code fragments
|
||||
yield (verify, u'::\n\n @Γ\\∞${}', None,
|
||||
u'\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n'
|
||||
@ -136,4 +136,4 @@ def test_latex_escaping():
|
||||
u'\\end{Verbatim}')
|
||||
# in URIs
|
||||
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