Repository: mrf345/flask_minify (language: python)

Issue:
Line breaks minifying to a space
I think this may be the same issue reported in #47, but it was self-closed and I didn't find the author's solution satisfying.

Basically, I'm seeing confusing behavior about how line breaks are minified. For example, below is the content of my Jinja2 HTML template (leading spaces intentionally kept in to reflect how it looks in my code):
```html
    <nav class="navbar bg-primary fixed-top navbar-expand-md">
      <div class="container-fluid">
        <button
          class="navbar-toggler"
          type="button"
        >
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="nav-collapse">
```

It got minified to the following, with spaces between the tags:
```html
<nav class="navbar bg-primary fixed-top navbar-expand-md"> <div class="container-fluid"> <button class="navbar-toggler" type="button"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="nav-collapse">
```

It's not consistent, though. At the top of that same file (my top-level layout template), I have:
```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="manifest" href="/manifest.json" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="mobile-web-app-capable" content="yes" />
    <meta name="theme-color" content="#2c3e50" />
```
And that correctly minifies to:
```html
<!DOCTYPE html><html lang="en"> <head><link rel="manifest" href="/manifest.json"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="mobile-web-app-capable" content="yes"><meta name="theme-color" content="#2c3e50">
```
Any ideas what's going on? It's not the end of the world but as long as I'm saving bytes, I want to save ALL the bytes. Thanks!


Discussion / hints:
After I posted, this I noticed there's a single space between `<html lang="en">` and `<head>` in my clean example above, so now I'm really confused. 
It's an option that can be enabled for `htmlmin`, this should it:

```python
from flask_minify import Minify
from flask_minify.parsers import Html as HtmlParser


class CustomHtmlParser(HtmlParser):
     runtime_options = {**HtmlParser.runtime_options, "remove_empty_space": True}


# initiating the extension
Minify(app=app, parsers={'html': CustomHtmlParser})
```

checkout https://github.com/mrf345/flask_minify#--parsers for more info
Why isn't that option enabled by default? It seems reasonable to me...

Fix patch:
diff --git a/flask_minify/about.py b/flask_minify/about.py
index cb85a36..955d055 100644
--- a/flask_minify/about.py
+++ b/flask_minify/about.py
@@ -1,4 +1,4 @@
-__version__ = "0.41"
+__version__ = "0.42"
 __doc__ = "Flask extension to minify html, css, js and less."
 __license__ = "MIT"
 __author__ = "Mohamed Feddad"
diff --git a/flask_minify/parsers.py b/flask_minify/parsers.py
index a91600e..f0ef5f7 100644
--- a/flask_minify/parsers.py
+++ b/flask_minify/parsers.py
@@ -43,6 +43,7 @@ class Html(ParserMixin):
     runtime_options = _o = {
         "remove_comments": True,
         "remove_optional_attribute_quotes": False,
+        "remove_empty_space": True,
         "only_html_content": False,
         "script_types": [],
         "minify_inline": _default_tags,


Test patch:
diff --git a/tests/constants.py b/tests/constants.py
index 7bfb84f..fe9321d 100644
--- a/tests/constants.py
+++ b/tests/constants.py
@@ -82,7 +82,7 @@
     ]
 )
 
-MINIFED_HTML = b"<html> <body> <h1> HTML </h1> </body> </html>"
+MINIFED_HTML = b"<html><body><h1> HTML </h1></body></html>"
 
 MINIFIED_JS = b'<script>["J","S"].reduce(function(a,r){return a+r})</script>'
 
@@ -107,13 +107,13 @@
 MINIFED_HTML_EMBEDDED_TAGS = bytes(
     "".join(
         [
-            "<html> ",
+            "<html>",
             MINIFIED_JS.decode("utf-8"),
-            ' <script type="text/script" src="testing/88.js"></script> ',
+            '<script type="text/script" src="testing/88.js"></script>',
             MINIFED_LESS.decode("utf-8"),
-            ' <script type="application/script" src="testing/1.js"></script> ',
+            '<script type="application/script" src="testing/1.js"></script>',
             MINIFIED_JS.decode("utf-8"),
-            ' <script src="testing/nested/2.js"></script> </html>',
+            '<script src="testing/nested/2.js"></script></html>',
         ]
     ).encode("utf-8")
 )