Syntax highlighting of automake files (

Issue #995 resolved
fluzz created an issue

The "if" keyword is used in files to conditionally create Makefiles (see

Currently, the "if" keyword is not recognized by the MakefileLexer, and thus an "err" token is generated (see

So, please, could you add "if" in the keywords list of MakefileLexer ?

Thx for your great work !

Comments (4)

  1. Lev Lozhkin

    Here's a quick patch that will give the desired behavior. I went for clarity, although that made part of the regex redundant.

    diff -r 2ba9b53c87ee pygments/lexers/
    --- a/pygments/lexers/   Tue May 20 07:44:45 2014 -0700
    +++ b/pygments/lexers/   Wed May 21 10:26:38 2014 -0700
    @@ -189,7 +189,9 @@
             # BSD Make
             # GNU Make
    -        r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:))(?=\s)')
    +        r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:)|'
    +        # GNU Automake
    +        r'\s*(if|else|endif))(?=\s)')
         r_comment = re.compile(r'^\s*@?#')
         def get_tokens_unprocessed(self, text):
  2. fluzz reporter

    I locally "hack-fixed" it by adding 'if' in GNU Make part of the regexp, just because I was wondering if redundancy would not have a bad impact on efficiency (I'm not at all a python expert, though).

    May I expect your patch to be commited for next release ?


  3. Log in to comment