2007-10-21 20:55:29 -04:00
|
|
|
import color, mode, mode.text, method, ispell
|
2007-10-21 20:52:48 -04:00
|
|
|
from lex import Token, Rule, PatternRule, RegionRule, Grammar
|
2007-08-14 09:43:23 -04:00
|
|
|
from mode.text import WordRule, ContinuedRule
|
|
|
|
|
|
|
|
class Text2Grammar(Grammar):
|
|
|
|
rules = [
|
2008-03-16 01:23:14 -04:00
|
|
|
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 ]+'),
|
2007-08-14 09:43:23 -04:00
|
|
|
ContinuedRule(),
|
|
|
|
WordRule(),
|
|
|
|
PatternRule(r'punct', r'[^a-zA-Z0-9_]'),
|
|
|
|
PatternRule(r'stuff', r'[a-zA-Z0-9_]+'),
|
|
|
|
]
|
|
|
|
|
|
|
|
class Text2(mode.text.Text):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'Text2'
|
|
|
|
grammar = Text2Grammar
|
|
|
|
extensions = ['.txt']
|
2008-01-29 13:07:13 -05:00
|
|
|
extensions = []
|
2007-10-18 17:07:35 -04:00
|
|
|
colors = {
|
2008-03-16 01:23:14 -04:00
|
|
|
'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'),
|
2007-08-14 09:43:23 -04:00
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = Text2.install
|