Skip to content

Commit 96eaf27

Browse files
author
jneen
committed
apache: more detailed scanning of values
1 parent 976ed57 commit 96eaf27

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/rouge/lexers/apache.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class Apache < RegexLexer
1717
end
1818

1919
def name_for_token(token, tktype)
20+
token = token.downcase
21+
2022
if SECTIONS.include? token
2123
tktype
2224
elsif DIRECTIVES.include? token
@@ -37,12 +39,12 @@ def name_for_token(token, tktype)
3739
mixin :whitespace
3840

3941
rule %r/(<\/?)(\w+)/ do |m|
40-
groups Punctuation, name_for_token(m[2].downcase, Name::Label)
42+
groups Punctuation, name_for_token(m[2], Name::Label)
4143
push :section
4244
end
4345

4446
rule %r/\w+/ do |m|
45-
token name_for_token(m[0].downcase, Name::Class)
47+
token name_for_token(m[0], Name::Class)
4648
push :directive
4749
end
4850
end
@@ -64,8 +66,22 @@ def name_for_token(token, tktype)
6466
mixin :whitespace
6567

6668
rule %r/\S+/ do |m|
67-
token name_for_token(m[0].downcase, Literal::String::Symbol)
69+
if VALUES.include?(m[0].downcase)
70+
token Literal::String::Symbol
71+
else
72+
fallthrough!
73+
end
6874
end
75+
76+
rule(%r/(?=\S)/) { push :value }
77+
end
78+
79+
state :value do
80+
rule %r/[ \t]+/, Text, :pop!
81+
rule %r/[^\s%]+/, Text
82+
rule %r/%{.*?}/, Name::Variable
83+
rule %r/[%]/, Text
84+
rule(/(?=\n)/) { pop! }
6985
end
7086
end
7187
end

0 commit comments

Comments
 (0)