Line continuation support in .ini files

Issue #494 new
Anonymous created an issue

There's no official standard for this, but it seems to be common where multi-line values are needed in .ini files to use a leading space (as opposed to a trailing ''/'') on subsequent lines of the value.

Here's a simple patch to make IniLexer be able to handle these types of multi-line values in an ini file.




--- (revision 5327) +++ (working copy) @@ -54,7 +54,7 @@ (r'\s+', Text), (r'[;#].?$', Comment), (r'\[.?\]$', Keyword), - (r'(.?)([ \t])(=)([ \t])(.?)$', + (r'(.?)([ \t])(=)([ \t])((\n |[^\n;#]))', bygroups(Name.Attribute, Text, Operator, Text, String)) ] } }}}

The match for the value is either a newline followed by a single space or anything up to a standalone newline or comment.

The only drawback to this patch is that it would no longer allow leading spaces before the keys themselves. Whitespace after the key and before and after the equals sign would continue to be recognized properly. I don't think that is common, but Pygments would currently recognize it, so it's worth pointing out.

Reported by guest

Comments (1)

  1. Anonymous

    I'd like to have this feature as well, the patch works fine for me.

    (and please fix the ''Add to Cc:'' stuff, I'm not brian428@ ... and don't want to change the user preferences for "guest", simplest thing is to give the TICKET_EDIT_CC permission to ''guest'' user)

  2. Log in to comment