Skip to content

Instantly share code, notes, and snippets.

@willthemoor
Created April 28, 2019 19:46
Show Gist options
  • Save willthemoor/81a22822504b13a3b69b1478a2c8fff6 to your computer and use it in GitHub Desktop.
Save willthemoor/81a22822504b13a3b69b1478a2c8fff6 to your computer and use it in GitHub Desktop.
Clean up HTML with comments and blank lines

Clean up HTML with twig template suggestion comments, etc.

In Atom anyway, with Regex enabled, find/replace:

1. Get rid of comments with:

Find: (?=<!--)([\s\S]*?)-->
Replace: ""

2. Clean up blank lines with:

Find: \n+
Replace: \n

NB: Blank lines replace presumes "Remove trailing spaces" is enabled. Otherwise, try:

Find: ^(?:[\t ]*(?:\r?\n|\r))+,
Replace: ""

Of course: https://stackoverflow.com/a/1732454/3189029

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