From dbbf9e7190beac15b44f679a97f90694ac69238c Mon Sep 17 00:00:00 2001 From: Tan Le Date: Fri, 23 Aug 2024 11:58:31 +1000 Subject: [PATCH] Handle `else if` statement in makefile --- lib/rouge/lexers/make.rb | 4 ++++ spec/visual/samples/make | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/rouge/lexers/make.rb b/lib/rouge/lexers/make.rb index 7320632ecf..3b7338325c 100644 --- a/lib/rouge/lexers/make.rb +++ b/lib/rouge/lexers/make.rb @@ -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 diff --git a/spec/visual/samples/make b/spec/visual/samples/make index c6a0aef84f..4581a31ba2 100644 --- a/spec/visual/samples/make +++ b/spec/visual/samples/make @@ -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