Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MCTaylor17 opened this issue Dec 11, 2017 · 7 comments
Open

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

MCTaylor17 opened this issue Dec 11, 2017 · 7 comments

Comments

@MCTaylor17
Copy link

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.

@oleggromov
Copy link

I'm having the same issue here.

@abhishek-kumar-91
Copy link

I want to work on this issue, Can you assign me?

@bitwiseman
Copy link
Member

@abhishek-kumar-91 No, I will not assign. But you should feel free to work on this.

@Kyathirao
Copy link

@bitwiseman can I work on this issue?

@bitwiseman
Copy link
Member

Yes.

@serhiyupw
Copy link

serhiyupw commented Nov 28, 2023

For example, instead of using regular space characters, you can use   HTML entity to represent the whitespace. This way, when the HTML comments are beautified, the whitespace will be preserved.

<p>
  This is some text with an HTML comment:
  <!--&nbsp;This is a comment&nbsp;-->
</p>

@bitwiseman
Copy link
Member

@serhiyupw
I don't think that applies here. HTML entity tags don't get interpreted in comments and the issue isn't what is inside the comment tag but its positioning due to elements outside the tag.

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

No branches or pull requests

6 participants