From 01f3e4e99fa951f69da4d4de931a2c9784b921e1 Mon Sep 17 00:00:00 2001 From: jmzambon Date: Fri, 26 Aug 2022 18:54:27 +0200 Subject: [PATCH] Fix syntax highlighting of INI language doesn't parse comments present on same line #2161 Add also support for line continuation in values and comments. --- pygments/lexers/configs.py | 9 +++++++-- tests/examplefiles/ini/test.ini | 12 +++++++++--- tests/examplefiles/ini/test.ini.output | 6 ++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pygments/lexers/configs.py b/pygments/lexers/configs.py index 1209e4e70f..963503e2a4 100644 --- a/pygments/lexers/configs.py +++ b/pygments/lexers/configs.py @@ -46,11 +46,16 @@ class IniLexer(RegexLexer): (r'\s+', Whitespace), (r'[;#].*', Comment.Single), (r'\[.*?\]$', Keyword), - (r'(.*?)([ \t]*)(=)([ \t]*)([^\t\n]*)', + (r'(.*?)([  \t]*)(=)([  \t]*)([^;#\n]*[  \t]\\\n)', + bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String), "value"), + (r'(.*?)([  \t]*)(=)([  \t]*)([^;#\n]*)', bygroups(Name.Attribute, Whitespace, Operator, Whitespace, String)), - # standalone option, supported by some INI parsers + # # standalone option, supported by some INI parsers (r'(.+?)$', Name.Attribute), ], + 'value': [ # line continuation + (r'[^;#=]+(?