Skip to content

Add support for multiline values#14

Open
dangmai wants to merge 1 commit intoZachPerkitny:masterfrom
dangmai:multiline-value
Open

Add support for multiline values#14
dangmai wants to merge 1 commit intoZachPerkitny:masterfrom
dangmai:multiline-value

Conversation

@dangmai
Copy link

@dangmai dangmai commented Nov 19, 2023

This PR adds support for both reading and writing multiline values.

There are multiple examples in Python's configparser docs about this scenario: https://docs.python.org/3/library/configparser.html#supported-ini-file-structure
I've tried to handle as many edge cases as I can based off of those examples. I've also added tests for a few example cases.

Fixes #4

* @private
*/
const SECTION = new RegExp(/^\s*\[([^\]]+)]$/);
const SECTION = new RegExp(/^(?<indent>\s*)\[(?<sectionName>[^\]]+)]$/);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switch the RegExp to use named groups, so that it's easier to reference them later in the code (vs referencing by index number)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fails to read a configuration with long lines

1 participant