Python pygments.token.string_to_tokentype() Examples
The following are 5
code examples of pygments.token.string_to_tokentype().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygments.token
, or try the search function
.
Example #1
Source File: pgstyle.py From pgcli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def parse_pygments_style(token_name, style_object, style_dict): """Parse token type and style string. :param token_name: str name of Pygments token. Example: "Token.String" :param style_object: pygments.style.Style instance to use as base :param style_dict: dict of token names and their styles, customized to this cli """ token_type = string_to_tokentype(token_name) try: other_token_type = string_to_tokentype(style_dict[token_name]) return token_type, style_object.styles[other_token_type] except AttributeError: return token_type, style_dict[token_name]
Example #2
Source File: clistyle.py From litecli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def parse_pygments_style(token_name, style_object, style_dict): """Parse token type and style string. :param token_name: str name of Pygments token. Example: "Token.String" :param style_object: pygments.style.Style instance to use as base :param style_dict: dict of token names and their styles, customized to this cli """ token_type = string_to_tokentype(token_name) try: other_token_type = string_to_tokentype(style_dict[token_name]) return token_type, style_object.styles[other_token_type] except AttributeError as err: return token_type, style_dict[token_name]
Example #3
Source File: clistyle.py From athenacli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def parse_pygments_style(token_name, style_object, style_dict): """Parse token type and style string. :param token_name: str name of Pygments token. Example: "Token.String" :param style_object: pygments.style.Style instance to use as base :param style_dict: dict of token names and their styles, customized to this cli """ token_type = string_to_tokentype(token_name) try: other_token_type = string_to_tokentype(style_dict[token_name]) return token_type, style_object.styles[other_token_type] except AttributeError as err: return token_type, style_dict[token_name]
Example #4
Source File: test_token.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_functions(): assert token.is_token_subtype(token.String, token.String) assert token.is_token_subtype(token.String, token.Literal) assert not token.is_token_subtype(token.Literal, token.String) assert token.string_to_tokentype(token.String) is token.String assert token.string_to_tokentype('') is token.Token assert token.string_to_tokentype('String') is token.String
Example #5
Source File: mssqlstyle.py From mssql-cli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def parse_pygments_style(token_name, style_object, style_dict): """Parse token type and style string. :param token_name: str name of Pygments token. Example: "Token.String" :param style_object: pygments.style.Style instance to use as base :param style_dict: dict of token names and their styles, customized to this cli """ token_type = string_to_tokentype(token_name) try: other_token_type = string_to_tokentype(style_dict[token_name]) return token_type, style_object.styles[other_token_type] except AttributeError: return token_type, style_dict[token_name]