|
44 | 44 | v: k for k, v in TOKEN_TO_PROMPT_STYLE.items() |
45 | 45 | } |
46 | 46 |
|
| 47 | +# all tokens that the Pygments MySQL lexer can produce |
| 48 | +OVERRIDE_STYLE_TO_TOKEN = { |
| 49 | + 'sql.comment': Token.Comment, |
| 50 | + 'sql.comment.multi-line': Token.Comment.Multiline, |
| 51 | + 'sql.comment.single-line': Token.Comment.Single, |
| 52 | + 'sql.comment.optimizer-hint': Token.Comment.Special, |
| 53 | + 'sql.escape': Token.Error, |
| 54 | + 'sql.keyword': Token.Keyword, |
| 55 | + 'sql.datatype': Token.Keyword.Type, |
| 56 | + 'sql.literal': Token.Literal, |
| 57 | + 'sql.literal.date': Token.Literal.Date, |
| 58 | + 'sql.symbol': Token.Name, |
| 59 | + 'sql.quoted-schema-object': Token.Name.Quoted, |
| 60 | + 'sql.quoted-schema-object.escape': Token.Name.Quoted.Escape, |
| 61 | + 'sql.constant': Token.Name.Constant, |
| 62 | + 'sql.function': Token.Name.Function, |
| 63 | + 'sql.variable': Token.Name.Variable, |
| 64 | + 'sql.number': Token.Number, |
| 65 | + 'sql.number.binary': Token.Number.Bin, |
| 66 | + 'sql.number.float': Token.Number.Float, |
| 67 | + 'sql.number.hex': Token.Number.Hex, |
| 68 | + 'sql.number.integer': Token.Number.Integer, |
| 69 | + 'sql.operator': Token.Operator, |
| 70 | + 'sql.punctuation': Token.Punctuation, |
| 71 | + 'sql.string': Token.String, |
| 72 | + 'sql.string.double-quouted': Token.String.Double, |
| 73 | + 'sql.string.escape': Token.String.Escape, |
| 74 | + 'sql.string.single-quoted': Token.String.Single, |
| 75 | + 'sql.whitespace': Token.Text, |
| 76 | +} |
47 | 77 |
|
48 | 78 | def parse_pygments_style(token_name, style_object, style_dict): |
49 | 79 | """Parse token type and style string. |
@@ -108,6 +138,9 @@ def style_factory_output(name, cli_style): |
108 | 138 | elif token in PROMPT_STYLE_TO_TOKEN: |
109 | 139 | token_type = PROMPT_STYLE_TO_TOKEN[token] |
110 | 140 | style.update({token_type: cli_style[token]}) |
| 141 | + elif token in OVERRIDE_STYLE_TO_TOKEN: |
| 142 | + token_type = OVERRIDE_STYLE_TO_TOKEN[token] |
| 143 | + style.update({token_type: cli_style[token]}) |
111 | 144 | else: |
112 | 145 | # TODO: cli helpers will have to switch to ptk.Style |
113 | 146 | logger.error('Unhandled style / class name: %s', token) |
|
0 commit comments