lib/rouge/lexers/jinja.rb in rouge-3.4.1 vs lib/rouge/lexers/jinja.rb in rouge-3.5.0
- old
+ new
@@ -35,91 +35,91 @@
@@word_operators ||= %w(is in and or not)
end
state :root do
# Comments
- rule /{#/, Comment, :comment
+ rule %r/{#/, Comment, :comment
# Statements
- rule /\{\%/ do
+ rule %r/\{\%/ do
token Comment::Preproc
push :statement
end
# Expressions
- rule /\{\{/ do
+ rule %r/\{\{/ do
token Comment::Preproc
push :expression
end
rule(/(.+?)(?=\\|{{|{%|{#)/m) { delegate parent }
rule(/.+/m) { delegate parent }
end
state :filter do
# Filters are called like variable|foo(arg1, ...)
- rule /(\|)(\w+)/ do
+ rule %r/(\|)(\w+)/ do
groups Operator, Name::Function
end
end
state :function do
- rule /(\w+)(\()/ do
+ rule %r/(\w+)(\()/ do
groups Name::Function, Punctuation
end
end
state :text do
- rule /\s+/m, Text
+ rule %r/\s+/m, Text
end
state :literal do
# Strings
- rule /"(\\.|.)*?"/, Str::Double
- rule /'(\\.|.)*?'/, Str::Single
+ rule %r/"(\\.|.)*?"/, Str::Double
+ rule %r/'(\\.|.)*?'/, Str::Single
# Numbers
- rule /\d+(?=}\s)/, Num
+ rule %r/\d+(?=}\s)/, Num
# Arithmetic operators (+, -, *, **, //, /)
# TODO : implement modulo (%)
- rule /(\+|\-|\*|\/\/?|\*\*?|=)/, Operator
+ rule %r/(\+|\-|\*|\/\/?|\*\*?|=)/, Operator
# Comparisons operators (<=, <, >=, >, ==, ===, !=)
- rule /(<=?|>=?|===?|!=)/, Operator
+ rule %r/(<=?|>=?|===?|!=)/, Operator
# Punctuation (the comma, [], ())
- rule /,/, Punctuation
- rule /\[/, Punctuation
- rule /\]/, Punctuation
- rule /\(/, Punctuation
- rule /\)/, Punctuation
+ rule %r/,/, Punctuation
+ rule %r/\[/, Punctuation
+ rule %r/\]/, Punctuation
+ rule %r/\(/, Punctuation
+ rule %r/\)/, Punctuation
end
state :comment do
rule(/[^{#]+/m) { token Comment }
rule(/#}/) { token Comment; pop! }
end
state :expression do
- rule /\w+\.?/m, Name::Variable
+ rule %r/\w+\.?/m, Name::Variable
mixin :filter
mixin :function
mixin :literal
mixin :text
- rule /%}|}}/, Comment::Preproc, :pop!
+ rule %r/%}|}}/, Comment::Preproc, :pop!
end
state :statement do
- rule /(raw|verbatim)(\s+)(\%\})/ do
+ rule %r/(raw|verbatim)(\s+)(\%\})/ do
groups Keyword, Text, Comment::Preproc
goto :raw
end
- rule /(\w+\.?)/ do |m|
+ rule %r/(\w+\.?)/ do |m|
if self.class.keywords.include?(m[0])
groups Keyword
elsif self.class.pseudo_keywords.include?(m[0])
groups Keyword::Pseudo
elsif self.class.word_operators.include?(m[0])
@@ -134,19 +134,19 @@
mixin :filter
mixin :function
mixin :literal
mixin :text
- rule /\%\}/, Comment::Preproc, :pop!
+ rule %r/\%\}/, Comment::Preproc, :pop!
end
state :raw do
rule %r{(\{\%)(\s+)(endverbatim|endraw)(\s+)(\%\})} do
groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
pop!
end
- rule /(.+?)/m, Text
+ rule %r/(.+?)/m, Text
end
end
end
end