lib/rouge/lexers/c.rb in rouge-3.27.0 vs lib/rouge/lexers/c.rb in rouge-3.28.0
- old
+ new
@@ -168,15 +168,25 @@
rule %r/\\\n/, Str
rule %r/\\/, Str # stray backslash
end
state :macro do
- # NB: pop! goes back to :bol
- rule %r/\n/, Comment::Preproc, :pop!
+ mixin :include
rule %r([^/\n\\]+), Comment::Preproc
rule %r/\\./m, Comment::Preproc
mixin :inline_whitespace
rule %r(/), Comment::Preproc
+ # NB: pop! goes back to :bol
+ rule %r/\n/, Comment::Preproc, :pop!
+ end
+
+ state :include do
+ rule %r/(include)(\s*)(<[^>]+>)([^\n]*)/ do
+ groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single
+ end
+ rule %r/(include)(\s*)("[^"]+")([^\n]*)/ do
+ groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single
+ end
end
state :if_0 do
# NB: no \b here, to cover #ifdef and #ifndef
rule %r/^\s*#if/, Comment, :if_0