HTML formatter sends comments to a new line when the comment does not include a space as the first character
See original GitHub issueDescription
The HTML formatter sends comments to a new line when the comment does not include a space as the first character. It works properly when the HTML comment starts with any white space character. I believe the issue is here: https://github.com/beautify-web/js-beautify/blob/master/js/src/html/beautifier.js#L698
Input
The code looked like this before beautification:
<!--start button--><button>Click here</button><!--end button-->
Expected Output
The code should have looked like this after beautification:
<!--start button--><button>Click here</button><!--end button-->
Actual Output
The code actually looked like this after beautification:
<!--start button--><button>Click here</button>
<!--end button-->
To have this function properly add a space at the start of the second comment.
Input
The code looked like this before beautification:
<!--start button--><button>Click here</button><!-- end button-->
Actual Output
The code actually looked like this after beautification:
<!--start button--><button>Click here</button><!-- end button-->
Environment
I tested this on beautifier.io
Settings
{
"indent_size": "2",
"indent_char": " ",
"max_preserve_newlines": "-1",
"preserve_newlines": false,
"keep_array_indentation": false,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_before_conditional": false,
"unescape_strings": false,
"jslint_happy": false,
"end_with_newline": false,
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false,
"indent_empty_lines": false
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
HTML Comments - W3Schools
HTML comments are not displayed in the browser, but they can help document your HTML source code. HTML Comment Tag. You can add...
Read more >Render a string in HTML and preserve spaces and linebreaks
As part of that I have a description (retrieved from a db) that has spaces and new lines. When it is rendered the...
Read more >RFC 2822: Internet Message Format
RFC 2822 Internet Message Format April 2001 that wherever this standard allows for folding white space (not simply WSP characters), a CRLF may...
Read more >Aardvark Comment Format - The Open Group
Review comments or `bugs' should be phrased wherever possible in terms of ... NOTE that page and line numbers must not include spaces:...
Read more >1. Creating Your First Page - Creating a Website - O'Reilly
Every web page you build along the way will be a bona fide HTML document. Note. The HTML standard doesn't have anything to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would like to work on this @avigoldman @aashigupta19
To clarify, I think the requested behavior is that the following input remains unchanged: