예제 #1
0
def convert(source, _lex):
    lexer = get_lexer_by_name(_lex)
    data = highlight(
        source, lexer,
        BBCodeFormatter(codetag=True,
                        style=get_style_by_name('default'),
                        monofont=True))
    return data
예제 #2
0
 def __init__(self, **kwargs):
     self.formatter = BBCodeFormatter()
     self.lexer = lexers.PythonLexer()
     self.text_color = '#000000'
     self._label_cached = Label()
     self.use_text_color = True
     super(CodeInput, self).__init__(**kwargs)
     self._line_options = kw = self._get_line_options()
     self._label_cached = Label(**kw)
     # use text_color as foreground color
     text_color = kwargs.get('foreground_color')
     if text_color:
         self.text_color = get_hex_from_color(text_color)
     # set foreground to white to allow text colors to show
     # use text_color as the default color in bbcodes
     self.use_text_color = False
     self.foreground_color = [1, 1, 1, .999]
     if not kwargs.get('background_color'):
         self.background_color = [.9, .92, .92, 1]
예제 #3
0
 def on_style(self, *args):
     self.formatter = BBCodeFormatter(style=self.style)
     self._trigger_update_graphics()