GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
LaTeX
Browse code
Added a PostgreSQL lexer
master
1 parent
4314c07
commit
1820db5b4a1c0a51faa399acefac1f6d736141e0
Nigel Stanger
authored
on 28 Mar 2022
Patch
Showing
1 changed file
minted/postgresql.py
Ignore Space
Show notes
View
minted/postgresql.py
0 → 100644
# -*- coding: utf-8 -*- """ PostgreSQL SQL lexer """ from pygments.lexers.sql import SqlLexer from pygments.token import Name, Keyword __all__ = ['PostgreSQLLexer'] class PostgreSQLLexer(SqlLexer): name = 'PostgreSQL' aliases = ['postgresql', 'postgres'] filenames = ['*.sql'] # just to have one if you want to use EXTRA_KEYWORDS = ['partition', 'over', 'rank', 'first_value', 'last_value', 'row_number', 'nulls', 'range', 'unbounded', 'preceding', 'following', 'trunc', 'nth_value', 'dense_rank', 'lag', 'lead', 'round', 'make_interval', 'date_trunc'] def get_tokens_unprocessed(self, text): for index, token, value in SqlLexer.get_tokens_unprocessed(self, text): if token is Name and value in self.EXTRA_KEYWORDS: yield index, Keyword, value else: yield index, token, value
Show line notes below