import color, mode, mode.text, method, ispell from lex import Token, Rule, PatternRule, RegionRule, Grammar from mode.text import WordRule, ContinuedRule class Text2Grammar(Grammar): rules = [ PatternRule(name=r'text2_email', pattern=r'(?:^|(?<=[ :]))@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'), PatternRule(name=r'text2_url', pattern=r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'), ContinuedRule(), WordRule(), PatternRule(r'punct', r'[^a-zA-Z0-9_]'), PatternRule(r'stuff', r'[a-zA-Z0-9_]+'), ] class Text2(mode.text.Text): modename = 'Text2' grammar = Text2Grammar extensions = ['.txt'] extensions = [] colors = { 'text2_email': ('cyan', 'default'), 'text2_url': ('green', 'default'), #'misspelled': ('red', 'default'), #'cont.start': ('default', 'default'), #'cont.end': ('default', 'default'), #'word': ('default', 'default'), #'punct': ('default', 'default'), #'stuff': ('default', 'default'), } install = Text2.install