def get_pygments_tokens(page, elem, uid): """inserts a table containing all existent token types and corresponding css class, with an example""" # The original div in the raw html page may contain some text # as a visual reminder that we need to remove here. elem.text = '' elem.attrib['class'] = CRUNCHY_PYGMENTS table = SubElement(elem, 'table') row = SubElement(table, 'tr') for title in ['Token type', 'css class']: column = SubElement(row, 'th') column.text = title keys = list(STANDARD_TYPES.keys()) keys.sort() for token in keys: if len(repr(token)) == 5: # token = Token continue row = SubElement(table, 'tr') column1 = SubElement(row, 'td') column1.text = repr(token)[6:] # remove "Token." column2 = SubElement(row, 'td') token_class = STANDARD_TYPES[token] column2.text = token_class.split('_')[0] column3 = SubElement(row, 'td') span = SubElement(column3, 'span') span.attrib['class'] = token_class span.text = " * test * " column4 = SubElement(row, 'td') _code = SubElement(column4, 'code') _code.attrib['class'] = token_class _code.text = " * test * " column5 = SubElement(row, 'td') var = SubElement(column5, 'var') var.attrib['class'] = token_class var.text = " * test * " return
import pygments from pygments.lexers import get_lexer_for_mimetype from pygments.lexers import TextLexer, IniLexer from pygments.styles import get_style_by_name from pygments.token import STANDARD_TYPES, Token from pygments.lexer import RegexLexer, bygroups from pygments.lexers import PythonLexer from pygments.token import * from pygments.formatters import * from pygments import highlight from pygments.formatter import Formatter except: print 'no pygments found, please install it first' STANDARD_TOKENS = STANDARD_TYPES.keys() tag_name = lambda sn, token: sn + '_' + str(token).replace('.', '_').lower() class textEditor(defaultValues): def __init__(self): defaultValues.__init__(self) self.pygLexer = None self.textbufferMisc = None self.viewMisc = None self.hl_style = None self._generated_styles = set() def getEditor(self, mime_type = 'text/x-tex', highlight = True):
# A Database and Query Analyze Tool # Copyright (c) 2010-2011 John Anderson <*****@*****.**> # License: GPLv3. See COPYING import gtk import pango import gobject from pygments.lexers import SqlLexer from pygments.styles import get_style_by_name from pygments.styles.colorful import ColorfulStyle from pygments.token import STANDARD_TYPES, Token from lib.common import _ from lib.pluginfactory import get_plugin STANDARD_TOKENS = STANDARD_TYPES.keys() tag_name = lambda sn, token: sn + '_' + str(token).replace('.', '_').lower() class PyQuilDocument(gtk.VBox): def __init__(self): super(gtk.VBox, self).__init__() self.hbox = gtk.HBox() self.__init_plugins() self.result_window = None self.plugin = None self.connection_string = gtk.Entry()