summaryrefslogtreecommitdiff
path: root/sphinx/highlighting.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2016-01-18 15:31:44 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2016-01-18 15:31:44 +0900
commit0329edc5107bae03342e7ca446a3d03ab8adeb13 (patch)
treea50a8b7f83067c6def504d67be31853511909902 /sphinx/highlighting.py
parent5574aba60ed76f2bae947722122ac4d71ab8ed5a (diff)
downloadsphinx-git-0329edc5107bae03342e7ca446a3d03ab8adeb13.tar.gz
Fix #1565: Show warning if Pygments throws an ErrorToken
Diffstat (limited to 'sphinx/highlighting.py')
-rw-r--r--sphinx/highlighting.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index 5d2f686dc..aa78b5b2e 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -183,9 +183,13 @@ class PygmentsBridge(object):
formatter = self.get_formatter(**kwargs)
try:
hlsource = highlight(source, lexer, formatter)
- except ErrorToken:
+ except ErrorToken as exc:
# this is most probably not the selected language,
# so let it pass unhighlighted
+ if warn:
+ warn('Could not parse literal_block as "%s". highlighting skipped.' % lang)
+ else:
+ raise exc
hlsource = highlight(source, lexers['none'], formatter)
if self.dest == 'html':
return hlsource