summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-04-13 09:49:02 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-04-13 09:49:02 +0100
commit98c745ccf4f94a129dae7f53a7db59277e0a06df (patch)
tree43802232e3e74e15c64cb7d2a9c7bc745437b39d
parent4f8f83415ac1a0e6c932e26a460fd83fa04e9811 (diff)
downloadpygments-98c745ccf4f94a129dae7f53a7db59277e0a06df.tar.gz
Detect multiline strings and error output in psql session
-rw-r--r--pygments/lexers/postgres.py6
-rw-r--r--tests/examplefiles/psql_session.txt11
2 files changed, 13 insertions, 4 deletions
diff --git a/pygments/lexers/postgres.py b/pygments/lexers/postgres.py
index 21185b30..501cc166 100644
--- a/pygments/lexers/postgres.py
+++ b/pygments/lexers/postgres.py
@@ -166,7 +166,7 @@ class PsqlRegexLexer(PostgresLexer):
(r"[^\s]+", String.Symbol),
]
-re_prompt = re.compile(r'^(\S.*?)??[=\-\(][#>]')
+re_prompt = re.compile(r'^(\S.*?)??[=\-\(\$\'\"][#>]')
re_psql_command = re.compile(r'\s*\\')
re_end_command = re.compile(r';\s*(--.*?)?$')
re_psql_command = re.compile(r'(\s*)(\\.+?)(\s+)$')
@@ -260,9 +260,7 @@ class PostgresConsoleLexer(Lexer):
out_token = Generic.Error
yield (mmsg.start(1), Generic.Strong, mmsg.group(1))
yield (mmsg.start(2), out_token, mmsg.group(2))
- elif re_charhint.match(line):
- yield (0, out_token, line)
else:
- yield (0, Generic.Output, line)
+ yield (0, out_token, line)
diff --git a/tests/examplefiles/psql_session.txt b/tests/examplefiles/psql_session.txt
index 565f7c33..fd87a133 100644
--- a/tests/examplefiles/psql_session.txt
+++ b/tests/examplefiles/psql_session.txt
@@ -42,6 +42,17 @@ regression(# 1);
1
(1 row)
+piro=> select (
+piro(> '
+piro'> ' || $$
+piro$> $$)
+piro-> from "
+piro"> foo";
+ERROR: relation "
+foo" does not exist
+LINE 5: from "
+ ^
+
testdb=> CREATE TABLE my_table (
first integer not null default 0,
second text) ; -- end of command