markdown quoting improvements

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2012-08-09 00:29:35 -04:00
parent 59631b0445
commit b3a29d3070
1 changed files with 30 additions and 13 deletions

View File

@ -12,21 +12,31 @@ from mode.scala import ScalaGrammar
from mode.sql import SqlGrammar from mode.sql import SqlGrammar
from mode.xml import XMLGrammar from mode.xml import XMLGrammar
class LineGrammar(Grammar): pass
LineGrammar.rules = [
PatternRule('line', r'.+'),
PatternRule('eol', r'\n'),
]
class MarkdownGrammar(Grammar): pass class MarkdownGrammar(Grammar): pass
MarkdownGrammar.rules = [ MarkdownGrammar.rules = [
PatternRule('md.head1', r'^# .+'), PatternRule('md.head1', r'^#.+'),
PatternRule('md.head2', r'^## .+'), PatternRule('md.head2', r'^##.+'),
PatternRule('md.head3', r'^### .+'), PatternRule('md.head3', r'^###.+'),
PatternRule('md.head4', r'^#### .+'), PatternRule('md.head4', r'^####.+'),
PatternRule('md.head5', r'^##### .+'), PatternRule('md.head5', r'^#####.+'),
PatternRule('md.head6', r'^###### .+'), PatternRule('md.head6', r'^######.+'),
PatternRule('md.bullet', r'^ *[\*\-\*] '), RegionRule('md.tag', r'^<(?P<tag>[a-zA-Z_][a-zA-Z0-9_]*)>$', HTMLGrammar, r'^</%(tag)s>$'),
PatternRule('md.bullet', r'^\s*[\*\-\*] '),
PatternMatchRule('', r'(\[.+?\])(\(.+?\))', 'md.linkname', 'md.linkurl'), PatternMatchRule('', r'(\[.+?\])(\(.+?\))', 'md.linkname', 'md.linkurl'),
PatternRule('md.block', r'^>\s.*$'), PatternRule('md.block3', r'^(?:>\s*>\s*>\s*)*>\s*>\s*>(?:[^>].*)?\n$'),
PatternRule('md.block2', r'^(?:>\s*>\s*>\s*)*>\s*>(?:[^>].*)?\n$'),
PatternRule('md.block1', r'^(?:>\s*>\s*>\s*)*>(?:[^>].*)?\n$'),
PatternRule('md.code', r'^(?: |\t).*$'), PatternRule('md.code', r'^(?: |\t).*$'),
PatternRule('md.inlinelink', r'http://[^`*\t(){}\[\] ]+'), PatternRule('md.inlinelink', r'http://[^`*\t(){}\[\] ]+'),
@ -40,7 +50,7 @@ MarkdownGrammar.rules = [
RegionRule('md.lang', r'^```sql$', SqlGrammar, r'^```'), RegionRule('md.lang', r'^```sql$', SqlGrammar, r'^```'),
RegionRule('md.lang', r'^```xml$', XMLGrammar, r'^```'), RegionRule('md.lang', r'^```xml$', XMLGrammar, r'^```'),
RegionRule('md.code', r'^```.+$', Grammar, r'^```'), RegionRule('md.code', r'^```.+$', LineGrammar, r'^```'),
RegionRule('md.bold', r'\*\*', MarkdownGrammar, r'\*\*'), RegionRule('md.bold', r'\*\*', MarkdownGrammar, r'\*\*'),
RegionRule('md.tt', r'``', MarkdownGrammar, r'``'), RegionRule('md.tt', r'``', MarkdownGrammar, r'``'),
@ -50,9 +60,9 @@ MarkdownGrammar.rules = [
PatternRule('md.word', r'[a-zA-Z\'"\-]+'), PatternRule('md.word', r'[a-zA-Z\'"\-]+'),
PatternRule('spaces', ' +'), PatternRule('spaces', '\s+'),
PatternRule('eol', ' +'), PatternRule('eol', r'\n'),
PatternRule('null', r'.'), #PatternRule('null', r'.'),
] ]
@ -105,9 +115,16 @@ class Markdown(Fundamental):
'md.head5': hi_blue, 'md.head5': hi_blue,
'md.head6': hi_blue, 'md.head6': hi_blue,
'md.tag.start': hi_magenta,
'md.tag.end': hi_magenta,
'md.linkname': hi_green, 'md.linkname': hi_green,
'md.linkurl': hi_cyan, 'md.linkurl': hi_cyan,
'md.block1': hi_yellow,
'md.block2': hi_orange,
'md.block3': hi_red,
'md.code': lo_green, 'md.code': lo_green,
'md.code.start': lo_green, 'md.code.start': lo_green,
'md.code.null': lo_green, 'md.code.null': lo_green,