Commits

Georg Brandl committed a110b16

Remove compatibility code for Pygments < 1.2.

Comments (0)

Files changed (2)

sphinx/highlighting.py

     # parser is not available on Jython
     parser = None
 
-from sphinx.util.texescape import tex_hl_escape_map_old, tex_hl_escape_map_new
+from sphinx.util.texescape import tex_hl_escape_map_new
 from sphinx.ext import doctest
 
 try:
         _lexer.add_filter('raiseonerror')
 
 
-escape_hl_chars = {ord(u'@'): u'@PYGZat[]',
-                   ord(u'['): u'@PYGZlb[]',
-                   ord(u']'): u'@PYGZrb[]'}
+escape_hl_chars = {ord(u'\\'): u'\\PYGZbs{}',
+                   ord(u'{'): u'\\PYGZob{}',
+                   ord(u'}'): u'\\PYGZcb{}'}
 
 # used if Pygments is not available
 _LATEX_STYLES = r'''
-\newcommand\PYGZat{@}
-\newcommand\PYGZlb{[}
-\newcommand\PYGZrb{]}
+\newcommand\PYGZbs{\char`\\}
+\newcommand\PYGZob{\char`\{}
+\newcommand\PYGZcb{\char`\}}
 '''
 
 parsing_exceptions = (SyntaxError, UnicodeEncodeError)
             # first, escape highlighting characters like Pygments does
             source = source.translate(escape_hl_chars)
             # then, escape all characters nonrepresentable in LaTeX
-            source = source.translate(tex_hl_escape_map_old)
-            return '\\begin{Verbatim}[commandchars=@\\[\\]]\n' + \
+            source = source.translate(tex_hl_escape_map_new)
+            return '\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + \
                    source + '\\end{Verbatim}\n'
 
     def try_parse(self, src):
             hlsource = highlight(source, lexer, formatter)
             if self.dest == 'html':
                 return hlsource
-            elif hlsource.startswith(r'\begin{Verbatim}[commandchars=\\\{\}'):
-                # Pygments >= 1.2
+            else:
                 return hlsource.translate(tex_hl_escape_map_new)
-            else:
-                return hlsource.translate(tex_hl_escape_map_old)
         except ErrorToken:
             # this is most probably not the selected language,
             # so let it pass unhighlighted

sphinx/util/texescape.py

 
 tex_escape_map = {}
 tex_replace_map = {}
-tex_hl_escape_map_old = {}  # replacement map for Pygments <= 1.1
-tex_hl_escape_map_new = {}  # replacement map for Pygments >= 1.2
-_old_cmd_chars = {ord(u'\\'): u'@', ord(u'{'): u'[', ord(u'}'): u']'}
+tex_hl_escape_map_new = {}
 
 def init():
     for a, b in tex_replacements:
     for a, b in tex_replacements:
         if a in u'[]{}\\': continue
         tex_hl_escape_map_new[ord(a)] = b
-        tex_hl_escape_map_old[ord(a)] = b.translate(_old_cmd_chars)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.