Daniele Varrazzo avatar Daniele Varrazzo committed 4c6fe77

psql can receive many backslash commands on the same line

Comments (0)

Files changed (2)

pygments/lexers/postgres.py

             (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),

tests/examplefiles/psql_session.txt

                ^
 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';
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.