Beispiel #1
0
 def __init__(self, editor, settings):
     self.editor = editor
     self.lexer = None
     self.settings = settings
     self.font_size = settings['Text Edit'].get('font size', 10)
     if robotframeworklexer:
         self.lexer = robotframeworklexer.RobotFrameworkLexer()
         self._set_styles()
     else:
         self.editor.GetParent().create_syntax_colorization_help()
Beispiel #2
0
 def __init__(self, editor, settings):
     self.editor = editor
     self.lexer = None
     self.settings = settings
     if robotframeworklexer:
         self.lexer = robotframeworklexer.RobotFrameworkLexer()
         self._set_styles()
     else:
         self.editor.GetParent().create_syntax_colorization_help()
     PUBLISHER.subscribe(self.OnSettingsChanged, RideSettingsChanged)
Beispiel #3
0
 def __init__(self, editor, settings, readonly=False):
     self.editor = editor
     self.lexer = None
     self.settings = settings
     self._readonly = readonly
     self._ensure_default_font_is_valid()
     if robotframeworklexer:
         self.lexer = robotframeworklexer.RobotFrameworkLexer()
     else:
         self.editor.GetParent().create_syntax_colorization_help()
     self._set_styles(self._readonly)
     PUBLISHER.subscribe(self.OnSettingsChanged, RideSettingsChanged)
Beispiel #4
0
def pygments_directive(name, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
    try:
        if arguments[0] == 'robotframework':
            lexer = robotframeworklexer.RobotFrameworkLexer()
        else:
            lexer = get_lexer_by_name(arguments[0])
    except ValueError as err:
        raise ValueError(
            f'Invalid syntax highlighting language "{arguments[0]}".')
    # take an arbitrary option if more than one is given
    formatter = options and VARIANTS[options.keys()[0]] or DEFAULT
    # possibility to read the content from an external file
    filtered = [line for line in content if line.strip()]
    if len(filtered) == 1:
        path = filtered[0].replace('/', os.sep)
        if os.path.isfile(path):
            content = open(path, encoding="utf-8").read().splitlines()
    parsed = highlight(u'\n'.join(content), lexer, formatter)
    return [nodes.raw('', parsed, format='html')]