summaryrefslogtreecommitdiff
path: root/pygments/lexers/agile.py
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2012-12-23 00:51:25 +0100
committerRob Hoelz <rob@hoelz.ro>2012-12-23 00:51:25 +0100
commit77bd4c06daef5714736044c51933333daadb9d93 (patch)
tree78573df3ad043269769a995b84a77a5276600731 /pygments/lexers/agile.py
parent0e8dcebae2a71128a47f6e3ce061a3e3fab49a75 (diff)
downloadpygments-77bd4c06daef5714736044c51933333daadb9d93.tar.gz
Allow the use of multiple bracketing characters for comments/strings
ex. #`{{{ comment! }}} q {{{ string! }}}
Diffstat (limited to 'pygments/lexers/agile.py')
-rw-r--r--pygments/lexers/agile.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index 505c7df6..d693fab2 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -2025,33 +2025,33 @@ class Perl6Lexer(ExtendedRegexLexer):
def embedded_comment_callback(lexer, match, context):
# XXX this could be more efficient, but is fine for now
- index = Perl6Lexer.PERL6_OPEN_BRACKET_CHARS.index(match.group(1))
+ index = Perl6Lexer.PERL6_OPEN_BRACKET_CHARS.index(match.group(1)[0])
closing_char = Perl6Lexer.PERL6_CLOSE_BRACKET_CHARS[index]
text = context.text
- end_pos = text.find(closing_char, match.start() + len(match.group(1)))
+ end_pos = text.find(closing_char * len(match.group(1)), match.start() + len(match.group(1)))
if end_pos == -1:
end_pos = len(text)
- yield match.start(), Comment.Multiline, text[match.start() : end_pos + 1]
- context.pos = end_pos + 1
+ yield match.start(), Comment.Multiline, text[match.start() : end_pos + len(match.group(1))]
+ context.pos = end_pos + len(match.group(1))
def bracketed_string_callback(lexer, match, context):
# XXX this could be more efficient, but is fine for now
- index = Perl6Lexer.PERL6_OPEN_BRACKET_CHARS.index(match.group(1))
+ index = Perl6Lexer.PERL6_OPEN_BRACKET_CHARS.index(match.group(1)[0])
closing_char = Perl6Lexer.PERL6_CLOSE_BRACKET_CHARS[index]
text = context.text
- end_pos = text.find(closing_char, match.start() + len(match.group(1)))
+ end_pos = text.find(closing_char * len(match.group(1)), match.start() + len(match.group(1)))
if end_pos == -1:
end_pos = len(text)
- yield match.start(), String, text[match.start() : end_pos + 1]
- context.pos = end_pos + 1
+ yield match.start(), String, text[match.start() : end_pos + len(match.group(1))]
+ context.pos = end_pos + len(match.group(1))
tokens = {
'root' : [
- ( r'#`([' + PERL6_OPEN_BRACKET_CHARS + '])', embedded_comment_callback ),
+ ( r'#`([' + PERL6_OPEN_BRACKET_CHARS + ']+)', embedded_comment_callback ),
( r'#[^\n]*$', Comment.Singleline ),
( r'^(\s*)=begin\s+(\w+)\b.*?^\1=end\s+\2', Comment.Multiline ),
( _build_word_match(PERL6_KEYWORDS, PERL6_IDENTIFIER_CHARS), Keyword ),
@@ -2059,7 +2059,7 @@ class Perl6Lexer(ExtendedRegexLexer):
# copied from PerlLexer
( r'[$@%&][*][' + PERL6_IDENTIFIER_CHARS + ']+', Name.Variable.Global ),
( r'[$@%&][.^:?=!~]?[' + PERL6_IDENTIFIER_CHARS + ']+', Name.Variable ),
- ( r'(?:q|qq|Q)\s*([' + PERL6_OPEN_BRACKET_CHARS + '])', bracketed_string_callback ),
+ ( r'(?:q|qq|Q)\s*([' + PERL6_OPEN_BRACKET_CHARS + ']+)', bracketed_string_callback ),
# copied from PerlLexer
( r'0_?[0-7]+(_[0-7]+)*', Number.Oct ),
( r'0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*', Number.Hex ),