summaryrefslogtreecommitdiff
path: root/pygments/lexers/postgres.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/postgres.py')
-rw-r--r--pygments/lexers/postgres.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pygments/lexers/postgres.py b/pygments/lexers/postgres.py
index fe9a8a22..36717d4f 100644
--- a/pygments/lexers/postgres.py
+++ b/pygments/lexers/postgres.py
@@ -67,10 +67,14 @@ def language_callback(lexer, match):
rules deepcopy fails in this case.
"""
l = None
- # TODO: the language can also be before the string
- m = language_re.match(lexer.text[match.end():])
+ m = language_re.match(lexer.text[match.end():match.end()+100])
if m is not None:
l = lexer._get_lexer(m.group(1))
+ else:
+ m = list(language_re.finditer(
+ lexer.text[max(0, match.start()-100):match.start()]))
+ if m:
+ l = lexer._get_lexer(m[-1].group(1))
if l:
yield (match.start(1), String, match.group(1))