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
Related issues: #1337 #426
The code looked like this before beautification:
<!--start button--><button>Click here</button><!--end button-->
The code should have looked like this after beautification:
<!--start button--><button>Click here</button><!--end button-->
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.
The code looked like this before beautification:
<!--start button--><button>Click here</button><!-- end button-->
The code actually looked like this after beautification:
<!--start button--><button>Click here</button><!-- end button-->
I tested this on beautifier.io
{
"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
}
This looks similar to #1301, but it is not the same.
This problem is even more apparent if for something like:
<span><!--start button--><button>Click here</button><!--end button--></span>
Which turns into:
<span>
<!--start button--><button>Click here</button>
<!--end button-->
</span>
This adds space between <span>
and <button>
and space inside the <button>
. :sob:
I would like to work on this @avigoldman @aashigupta19
@cfya
Please do!
Most helpful comment
I would like to work on this @avigoldman @aashigupta19