from mode import Fundamental from lex import Grammar, PatternRule, RegionRule class MetadataGrammar(Grammar): rules = [PatternRule(r'username', r'[a-zA-Z0-9_]+')] class BlameGrammar(Grammar): rules = [ RegionRule(r'metadata', r'^[0-9\.]+', MetadataGrammar, r'(?:\d{4}-\d{2}-\d{2}|\d{2}-[A-Z][a-z]{2}-\d{2})'), PatternRule(r'data', r'.+$'), ] class Blame(Fundamental): name = 'Blame' grammar = BlameGrammar colors = { 'metadata.start': ('blue', 'default', 'bold'), 'metadata.username': ('cyan', 'default', 'bold'), 'metadata.end': ('green', 'default', 'bold'), } install = Blame.install