diff options
-rw-r--r-- | pygments/lexers/text.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py index 545702b9..8fd57bc5 100644 --- a/pygments/lexers/text.py +++ b/pygments/lexers/text.py @@ -634,7 +634,8 @@ class RstLexer(RegexLexer): tokens = { 'root': [ # Heading with overline - (r'^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)(.+)(\n)(\1)(\n)', + (r'^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)' + r'(.+)(\n)(\1)(\n)', bygroups(Generic.Heading, Text, Generic.Heading, Text, Generic.Heading, Text)), # Plain heading @@ -654,6 +655,9 @@ class RstLexer(RegexLexer): bygroups(Text, Number, using(this, state='inline'))), (r'^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1 .+\n)+)', bygroups(Text, Number, using(this, state='inline'))), + # Line blocks + (r'^(\s*)(\|)( .+\n(?:\| .+\n)*)', + bygroups(Text, Operator, using(this, state='inline'))), # Sourcecode directives (r'^( *\.\.)(\s*)((?:source)?code)(::)([ \t]*)([^\n]+)' r'(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*|)\n)+)', @@ -688,12 +692,13 @@ class RstLexer(RegexLexer): 'inline': [ (r'\\.', Text), # escape (r'``', String, 'literal'), # code - (r'(`)(.+?)(`__?)', - bygroups(Punctuation, using(this), Punctuation)), # reference + (r'(`.+?)(<.+?>)(`__?)', # reference with inline target + bygroups(String, String.Interpol, String)), + (r'`.+?`__?', String), # reference (r'(`.+?`)(:[a-zA-Z0-9-]+?:)?', bygroups(Name.Variable, Name.Attribute)), # role (r'(:[a-zA-Z0-9-]+?:)(`.+?`)', - bygroups(Name.Attribute, Name.Variable)), # user-defined role + bygroups(Name.Attribute, Name.Variable)), # role (content first) (r'\*\*.+?\*\*', Generic.Strong), # Strong emphasis (r'\*.+?\*', Generic.Emph), # Emphasis (r'\[.*?\]_', String), # Footnote or citation |