summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-02-28 22:27:15 +0100
committerGeorg Brandl <georg@python.org>2010-02-28 22:27:15 +0100
commit3cf9ca698cdafa6383f763de294323118de0a27e (patch)
treea07d69eb650c1c5857c8a6e984310ee3c6606ae3
parent5b92ae2c027adbeb1ea8f759bcdbf18cf7671c4e (diff)
downloadpygments-3cf9ca698cdafa6383f763de294323118de0a27e.tar.gz
RstLexer: recognize line blocks, better highlighting for references.
-rw-r--r--pygments/lexers/text.py13
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