diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-01-18 15:31:44 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-01-18 15:31:44 +0900 |
commit | 0329edc5107bae03342e7ca446a3d03ab8adeb13 (patch) | |
tree | a50a8b7f83067c6def504d67be31853511909902 /sphinx/highlighting.py | |
parent | 5574aba60ed76f2bae947722122ac4d71ab8ed5a (diff) | |
download | sphinx-git-0329edc5107bae03342e7ca446a3d03ab8adeb13.tar.gz |
Fix #1565: Show warning if Pygments throws an ErrorToken
Diffstat (limited to 'sphinx/highlighting.py')
-rw-r--r-- | sphinx/highlighting.py | 6 |
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 |