Skip to content

Commit

Permalink
Handle else if statement in makefile (#2063)
Browse files Browse the repository at this point in the history
  • Loading branch information
tancnle authored Aug 29, 2024
1 parent c5e4a8a commit 90b5c83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rouge/lexers/make.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def initialize(opts={})
groups Keyword, Text, Name::Variable
end

rule %r/(else\b)([\t ]+)((?:ifn?def|ifn?eq)\b)([\t ]+)([^#\n]+)/ do
groups Keyword, Text, Keyword, Text, Name::Variable
end

rule %r/(?:else|endif|endef|endfor)[\t ]*(?=[#\n])/, Keyword

rule %r/(export)([\t ]+)(?=[\w\${}()\t -]+\n)/ do
Expand Down
8 changes: 8 additions & 0 deletions spec/visual/samples/make
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ else
THING2 = default
endif

ifeq ($(OS), Linux)
MES = "Hi, Linux"
else ifeq ($(OS), Darwin)
MES = "Hi, Mac"
else
MES = "Unknown"
endif

ifeq ($(TARGET),special) # syntax variant: parentheses and separating comma
TARGET = something_else
else
Expand Down

0 comments on commit 90b5c83

Please sign in to comment.