diff --git a/pygments/lexers/configs.py b/pygments/lexers/configs.py index 1209e4e70f..c45849815a 100644 --- a/pygments/lexers/configs.py +++ b/pygments/lexers/configs.py @@ -46,7 +46,7 @@ class IniLexer(RegexLexer): (r'\s+', Whitespace), (r'[;#].*', Comment.Single), (r'\[.*?\]$', Keyword), - (r'(.*?)([ \t]*)(=)([ \t]*)([^\t\n]*)', + (r'(.*?)([  \t]*)(=)([  \t]*)([^;#\n]*)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)), # standalone option, supported by some INI parsers (r'(.+?)$', Name.Attribute), diff --git a/tests/examplefiles/ini/test.ini b/tests/examplefiles/ini/test.ini index a447803de7..f7056407e1 100644 --- a/tests/examplefiles/ini/test.ini +++ b/tests/examplefiles/ini/test.ini @@ -1,7 +1,7 @@ [section] -foo = bar -continued = foo +foo = bar ; inline comment +continued = foo # inline comment baz conttwo = foo diff --git a/tests/examplefiles/ini/test.ini.output b/tests/examplefiles/ini/test.ini.output index 4e7e3a59fb..9dd1d513fa 100644 --- a/tests/examplefiles/ini/test.ini.output +++ b/tests/examplefiles/ini/test.ini.output @@ -5,14 +5,16 @@ ' ' Text.Whitespace '=' Operator ' ' Text.Whitespace -'bar' Literal.String +'bar ' Literal.String +'; inline comment' Comment.Single '\n' Text.Whitespace 'continued' Name.Attribute ' ' Text.Whitespace '=' Operator ' ' Text.Whitespace -'foo' Literal.String +'foo ' Literal.String +'# inline comment' Comment.Single '\n ' Text.Whitespace 'baz' Name.Attribute '\n' Text.Whitespace