slomkowski / nginx-config-formatter

nginx config file formatter/beautifier written in Python with no additional dependencies.
Apache License 2.0
380 stars 64 forks source link

Corrected indentation to ignore unmatched quotes inside comments #23

Closed stoffus closed 3 years ago

stoffus commented 3 years ago

It seems the indentation logic is purely based on { and }, without taking the lines containing TEMPLATE_BRACKET_OPENING_TAG and TEMPLATE_BRACKET_CLOSING_TAG into consideration.

Unmatched quotes inside comments breaks the indentation.

Without the changes in this PR, blocks like this:

server {
    # My comment with an unmatched '
    location / {
        root /var/www/foo;
    }
}

will be transformed into this:

server {
    # My comment with an unmatched '
    location / {
    root /var/www/foo;
    }
}