def __pt_formatted_text__(self):
        result = FormattedText()

        for token, text in self.token_list:
            result.append(('class:' + pygments_token_to_classname(token), text))

        return result
Пример #2
0
def _pygments_token_to_classname(token):
    """Converts pygments Tokens, token names (strings) to PTK style names."""
    if token and isinstance(token, str):
        # if starts with non capital letter => leave it as it is
        if token[0].islower():
            return token
        # if starts with capital letter => pygments token name
        if token.startswith("Token."):
            token = token[6:]
        # short colors - all caps
        if token == token.upper():
            token = "color." + token
        return "pygments." + token.lower()

    return pygments_token_to_classname(token)
Пример #3
0
 def __missing__(self, key: Tuple[str, ...]) -> str:
     result = "class:" + pygments_token_to_classname(key)
     self[key] = result
     return result
 def __missing__(self, key):
     result = 'class:' + pygments_token_to_classname(key)
     self[key] = result
     return result
 def __missing__(self, key: Tuple[str, ...]) -> str:
     result = 'class:' + pygments_token_to_classname(key)
     self[key] = result
     return result
 def __missing__(self, key):
     result = 'class:' + pygments_token_to_classname(key)
     self[key] = result
     return result