beautifier/js-beautify

HTML <!-- comments --> placed within text alters whitespace

Ouverte

#1 301 ouverte le 11 déc. 2017

 (6 commentaires) (0 réaction) (0 personne assignée)JavaScript (1 460 forks)batch import
good first issuelanguage: htmltype: bug

Métriques du dépôt

Stars
 (8 342 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

Description

When HTML comments are beautified, it removes the whitespace surrounding the comment. This is problematic if the HTML comments occur within text blocks such as paragraphs.

Input

When a comment exists inside a text block:

<div><p>Hello <!-- Comment -->World</p></div>

Expected

Ideally, I would like comments to always be ignored wherever they occur, like so:

<div>
	<p>Hello <!-- Comment -->World</p>
</div>

Actual

The problem with the above is the removal of the space following Hello like so:

<div>
	<p>Hello
		<!-- Comment -->World</p>
</div>

Settings

Example:

{
	"indent_size": 1,
	"indent_char": "	",
	"wrap_line_length": 0,
	"preserve_newlines": true,
	"max_preserve_newlines": 3
}

Note

I'm aware that I could use:

{
	"content_unformatted": ["p","li","td", "...", "..."]
}

But this doesn't strike me as an ideal solution. I think it would be better if there was an option to ignore comment tags specifically.

Guide contributeur