Skip to content

need to retain space around inline, inline-block, and comment #151

@tisdall

Description

@tisdall

Currently django-htmlmin retains space around inline text elements. However, there are other inline/inline-block elements that still render whitespace around them that are currently not handled. Also, comment removal takes spaces outside the comment with it.

examples:

>>> from htmlmin.minify import html_minify
>>> html_minify('''<img src="http://example.com/image.jpg" alt="example">  hi''')
'<html><head></head><body><img alt="example" src="http://example.com/image.jpg"/>hi</body></html>'
>>> html_minify('''name: <input type="text">''')
'<html><head></head><body>name:<input type="text"/></body></html>'
>>> html_minify('''<p>a <!-- --> b</p>''')
'<html><head></head><body><p>ab</p></body></html>'
>>> html_minify('''<em>a <!-- --> b</em>''')  # this works as `em` is a text context
'<html><head></head><body><em>a  b</em></body></html>'
>>> html_minify('''<button> click me  </button>  text after''')
'<html><head></head><body><button>click me</button>text after</body></html>'

Some of these can be fixed by adding attributes to TEXT_FLOW, but they aren't really text elements so naming would probably need adjusting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions