summaryrefslogtreecommitdiff
path: root/sphinx/highlighting.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-11-08 17:00:56 +0100
committerGeorg Brandl <georg@python.org>2009-11-08 17:00:56 +0100
commitb0ee52829843b50d40cc4c17290f2670fab6bb2b (patch)
treef6b3634519d69b17b2734cf46a17de5fa9e9d6f8 /sphinx/highlighting.py
parentadad88b42915215bddbbeff720a536ab53f3373d (diff)
downloadsphinx-git-b0ee52829843b50d40cc4c17290f2670fab6bb2b.tar.gz
#265: restore Jython compatibility.
Diffstat (limited to 'sphinx/highlighting.py')
-rw-r--r--sphinx/highlighting.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index 5bd0fe00a..7663279c6 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -12,9 +12,14 @@
import sys
import cgi
import re
-import parser
import textwrap
+try:
+ import parser
+except ImportError:
+ # parser is not available on Jython
+ parser = None
+
from sphinx.util.texescape import tex_hl_escape_map
try:
@@ -155,6 +160,9 @@ class PygmentsBridge(object):
# just replace all non-ASCII characters.
src = src.encode('ascii', 'replace')
+ if parser is None:
+ return True
+
try:
parser.suite(src)
except parsing_exceptions: