diff --git a/code_examples/email b/code_examples/email new file mode 100644 index 0000000..1da8c19 --- /dev/null +++ b/code_examples/email @@ -0,0 +1,14 @@ +From: Erik Osheim +To: All Systems Go! +Date: Wednesday, April 8th 2009 +Subject: Ahoy! + +Quoth Alec Wood : +> I got this crazy email; here it is: +> +> Also sprach Emily Record : +>> This is double-quoted: +>> +>>> Hi there!!! + +This is outer text. diff --git a/mode/mutt.py b/mode/mutt.py index 8fd32d2..e73e31a 100644 --- a/mode/mutt.py +++ b/mode/mutt.py @@ -1,29 +1,30 @@ import re -import color, mode, method -import mode.text +from mode import Fundamental +from method import WrapParagraph +from mode.text import ContinuedRule, WordRule, TextInsertSpace from lex import Grammar, PatternRule class MuttGrammar(Grammar): rules = [ - PatternRule(name=r'mutt_header', pattern=r'^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'), - PatternRule(name=r'quoteb', pattern=r'^ *(?:(?: *>){3})*(?: *>){2}.*$'), - PatternRule(name=r'quotea', pattern=r'^ *(?:(?: *>){3})*(?: *>){1}.*$'), - PatternRule(name=r'quotec', pattern=r'^ *(?:(?: *>){3})*(?: *>){3}.*$'), - PatternRule(name=r'email', pattern=r'(?:^|(?<=[ :]))@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'), - PatternRule(name=r'url', pattern=r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'), - mode.text.ContinuedRule(), - mode.text.WordRule(), - PatternRule(name=r'punct', pattern=r'[^a-zA-Z0-9_]'), - PatternRule(name=r'stuff', pattern=r'[a-zA-Z0-9_]+'), + PatternRule('mutt_header', '^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'), + PatternRule('quotec', '^ *(?:(?: *>){3})*(?: *>){3}.*$'), + PatternRule('quoteb', '^ *(?:(?: *>){3})*(?: *>){2}.*$'), + PatternRule('quotea', '^ *(?:(?: *>){3})*(?: *>){1}.*$'), + PatternRule('email', r'(?:^|(?<=[ :]))@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'), + PatternRule('url', r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'), + ContinuedRule(), + WordRule(), + PatternRule('punct', '[^a-zA-Z0-9_]'), + PatternRule('stuff', '[a-zA-Z0-9_]+'), ] -class MuttWrapParagraph(method.WrapParagraph): +class MuttWrapParagraph(WrapParagraph): limit = 72 empty_re = re.compile('^(?: *>.*| *)$') -class MuttInsertSpace(mode.text.TextInsertSpace): +class MuttInsertSpace(TextInsertSpace): wrapper = MuttWrapParagraph -class Mutt(mode.Fundamental): +class Mutt(Fundamental): name = 'Mutt' grammar = MuttGrammar() colors = {