Skip to content

Commit

Permalink
Merge branch 'Epsirom-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mankyd committed Apr 25, 2015
2 parents ea65016 + c9ba2fe commit ecf4403
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion htmlmin/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def handle_startendtag(self, tag, attrs):
self._data_buffer.append(self.build_tag(tag, attrs, tag not in NO_CLOSE_TAGS))

def handle_comment(self, data):
if not self.remove_comments or data[0] == '!' or re.match(r'^\[if\s', data):
if not self.remove_comments or (
data and (data[0] == '!' or re.match(r'^\[if\s', data))):
self._data_buffer.append('<!--{}-->'.format(
data[1:] if data[0] == '!' else data))

Expand Down
2 changes: 1 addition & 1 deletion htmlmin/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
'<body><br><br> x </body>',
),
'remove_comments': (
'<body> this text should <!-- X --> have comments removed</body>',
'<body> this text should <!-- X --> have <!----> comments removed</body>',
'<body> this text should have comments removed</body>',
),
'keep_comments': (
Expand Down

0 comments on commit ecf4403

Please sign in to comment.