diff options
Diffstat (limited to 'pygments/util.py')
-rw-r--r-- | pygments/util.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pygments/util.py b/pygments/util.py index 9c84e8dc..94b1bd21 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -106,8 +106,9 @@ def shebang_matches(text, regex): Note that this method automatically searches the whole string (eg: the regular expression is wrapped in ``'^$'``) """ - if '\n' in text: - first_line = text[:text.index('\n')].lower() + index = text.find('\n') + if index >= 0: + first_line = text[:index].lower() else: first_line = text.lower() if first_line.startswith('#!'): |