threedaymonk / htmlbeautifier

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.
MIT License
325 stars 59 forks source link

Fix foreign block indentation issue #44

Closed manoj-krishnan closed 7 years ago

manoj-krishnan commented 7 years ago

The emit_reindented_block_content function was adding extra indents to line numbers > 1 when passed code which is already pre-indented. This causes the beautifier to actually add messy indentation to well indented foreign block code with each run. This fix resolves that problem. Unit tests added.

Screenshots of the problem Before Beautifying pre-beautify

After running beautify once post-beautify

After running beautify ~4 times (happens when code editor is set to use htmlbeautifier on save) post-4-beautifies

manoj-krishnan commented 7 years ago

Sorry about the initial commit breaking the build. I'm totally new to the rake environment and had to figure things out.

threedaymonk commented 7 years ago

Top work! I've merged it into master, and released a new gem version 1.3.1.

Thank you.

manoj-krishnan commented 7 years ago

Thanks for the quick turnaround!