658
655
bygroups(Text, Number, using(this, state='inline'))),
659
656
(r'^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1 .+\n)+)',
660
657
bygroups(Text, Number, using(this, state='inline'))),
659
(r'^(\s*)(\|)( .+\n(?:\| .+\n)*)',
660
bygroups(Text, Operator, using(this, state='inline'))),
661
661
# Sourcecode directives
662
662
(r'^( *\.\.)(\s*)((?:source)?code)(::)([ \t]*)([^\n]+)'
663
663
r'(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*|)\n)+)',
664
664
_handle_sourcecode),
666
(r'^( *\.\.)(\s*)([\w-]+)(::)(?:([ \t]*)(.+))?',
667
bygroups(Punctuation, Text, Operator.Word, Punctuation, Text, Keyword)),
666
(r'^( *\.\.)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
667
bygroups(Punctuation, Text, Operator.Word, Punctuation, Text,
668
using(this, state='inline'))),
668
669
# A reference target
669
670
(r'^( *\.\.)(\s*)([\w\t ]+:)(.*?)$',
670
671
bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
671
672
# A footnote target
672
673
(r'^( *\.\.)(\s*)(\[.+\])(.*?)$',
673
674
bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
676
(r'^( *\.\.)(\s*)(\|.+\|)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
677
bygroups(Punctuation, Text, Name.Tag, Text, Operator.Word,
678
Punctuation, Text, using(this, state='inline'))),
675
680
(r'^ *\.\..*(\n( +.*\n|\n)+)?', Comment.Preproc),
677
(r'^( *)(:.*?:)([ \t]+)(.*?)$', bygroups(Text, Name.Class, Text,
682
(r'^( *)(:[a-zA-Z-]+:)(\s*)$', bygroups(Text, Name.Class, Text)),
683
(r'^( *)(:.*?:)([ \t]+)(.*?)$',
684
bygroups(Text, Name.Class, Text, Name.Function)),
679
685
# Definition list
680
686
(r'^([^ ].*(?<!::)\n)((?:(?: +.*)\n)+)',
681
687
bygroups(using(this, state='inline'), using(this, state='inline'))),
688
694
(r'\\.', Text), # escape
689
695
(r'``', String, 'literal'), # code
691
bygroups(Punctuation, using(this), Punctuation)), # reference
692
(r'(`.+?`)(:[a-zA-Z0-9-]+?:)?',
696
(r'(`.+?)(<.+?>)(`__?)', # reference with inline target
697
bygroups(String, String.Interpol, String)),
698
(r'`.+?`__?', String), # reference
699
(r'(`.+?`)(:[a-zA-Z0-9:-]+?:)?',
693
700
bygroups(Name.Variable, Name.Attribute)), # role
694
(r'(:[a-zA-Z0-9-]+?:)(`.+?`)',
695
bygroups(Name.Attribute, Name.Variable)), # user-defined role
701
(r'(:[a-zA-Z0-9:-]+?:)(`.+?`)',
702
bygroups(Name.Attribute, Name.Variable)), # role (content first)
696
703
(r'\*\*.+?\*\*', Generic.Strong), # Strong emphasis
697
704
(r'\*.+?\*', Generic.Emph), # Emphasis
698
705
(r'\[.*?\]_', String), # Footnote or citation