1. cormullion
  2. pygments-main


Daniele Varrazzo  committed 4c6fe77

psql can receive many backslash commands on the same line

  • Participants
  • Parent commits 1203f76
  • Branches default

Comments (0)

Files changed (2)

File pygments/lexers/postgres.py

View file
             (r'(?ms)(\$[^\$]*\$)(.*?)(\1)', language_callback),
             (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
-            # TODO: consider splitting the regex parser
+            # TODO: consider splitting the psql parser
             (r'\\[^\s]+', Keyword.Pseudo, 'psql-command'),
             # psql variable in SQL
             (r""":(['"]?)[a-z][a-z0-9_]*\b\1""", Name.Variable),
         'psql-command': [
             (r'\n', Text, 'root'),
             (r'\s+', Text),
+            (r'\\[^\s]+', Keyword.Pseudo),
             (r""":(['"]?)[a-z][a-z0-9_]*\b\1""", Name.Variable),
             (r"'(''|[^'])*'", String.Single),
             (r"`([^`])*`", String.Backtick),

File tests/examplefiles/psql_session.txt

View file
 regression=# \q
+peter@localhost testdb=> \a \t \x
+Output format is aligned.
+Tuples only is off.
+Expanded display is on.
 regression=# select '\x';
 WARNING:  nonstandard use of escape in a string literal
 LINE 1: select '\x';