finesse.script.highlighter module

KatScript lexer for syntax highlighting with Pygments.

Note that this plugin is used in the documentation as well, it provides the syntax highlighting for the code-block:katscript directive

class finesse.script.highlighter.KatScriptPygmentsLexer(**options)[source]

Bases: Lexer

aliases = ['katscript', 'kat']

A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using get_lexer_by_name().

filenames = ['*.kat']

A list of fnmatch patterns that match filenames which contain content for this lexer. The patterns in this list should be unique among all lexers.

get_tokens_unprocessed(text)[source]

This method should process the text and return an iterable of (index, tokentype, value) tuples where index is the starting position of the token within the input text.

It must be overridden by subclasses. It is recommended to implement it as a generator to maximize effectiveness.

name = 'KatScript'

Full name of the lexer, in human-readable form

token_map = {'BOOLEAN': ('Keyword', 'Reserved'), 'COMMA': ('Punctuation',), 'COMMENT': ('Comment',), 'DIVIDE': ('Operator',), 'EQUALS': ('Operator',), 'LBRACKET': ('Punctuation',), 'LPAREN': ('Punctuation',), 'MINUS': ('Operator',), 'NAME': ('Text',), 'NEWLINE': ('Text',), 'NONE': ('Text',), 'NUMBER': ('Literal', 'Number'), 'PLUS': ('Operator',), 'RBRACKET': ('Punctuation',), 'REFERENCE': ('Name', 'Variable'), 'RPAREN': ('Punctuation',), 'STRING': ('Literal', 'String'), 'TIMES': ('Operator',), 'WHITESPACE': ('Text',)}
class finesse.script.highlighter.KatScriptSubstringPygmentsLexer(*args, **kwds)[source]

Bases: RegexLexer

aliases = ['katscriptinpython']

A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using get_lexer_by_name().

flags = 16

Flags for compiling the regular expressions. Defaults to MULTILINE.

name = 'KatScriptInPython'

Full name of the lexer, in human-readable form

tokens = {'katscript': [('(.*?)(""")', <function bygroups.<locals>.callback>, '#pop')], 'root': [('(.+?""")([\\s\\n]*#kat)', <function bygroups.<locals>.callback>, 'katscript'), ('.+', <function using.<locals>.callback>)]}

At all time there is a stack of states. Initially, the stack contains a single state ‘root’. The top of the stack is called “the current state”.

Dict of {'state': [(regex, tokentype, new_state), ...], ...}

new_state can be omitted to signify no state transition. If new_state is a string, it is pushed on the stack. This ensure the new current state is new_state. If new_state is a tuple of strings, all of those strings are pushed on the stack and the current state will be the last element of the list. new_state can also be combined('state1', 'state2', ...) to signify a new, anonymous state combined from the rules of two or more existing ones. Furthermore, it can be ‘#pop’ to signify going back one step in the state stack, or ‘#push’ to push the current state on the stack again. Note that if you push while in a combined state, the combined state itself is pushed, and not only the state in which the rule is defined.

The tuple can also be replaced with include('state'), in which case the rules from the state named by the string are included in the current one.