Permalink
Browse files

Removed treatment of html-comment as non-html

This is a UI only change but added a test to guard the engine.

Fixed #1068
  • Loading branch information...
1 parent f6409cc commit d2f8025239a06a5c2feccc5926df2d9190056cd7 @bitwiseman bitwiseman committed Dec 18, 2016
Showing with 32 additions and 4 deletions.
  1. +1 −4 index.html
  2. +14 −0 js/test/generated/beautify-html-tests.js
  3. +17 −0 test/data/html/tests.js
View
@@ -300,11 +300,8 @@
function looks_like_html(source) {
// <foo> - looks like html
- // <!--\nalert('foo!');\n--> - doesn't look like html
-
var trimmed = source.replace(/^[ \t\n\r]+/, '');
- var comment_mark = '<' + '!-' + '-';
- return (trimmed && (trimmed.substring(0, 1) === '<' && trimmed.substring(0, 4) !== comment_mark));
+ return trimmed && (trimmed.substring(0, 1) === '<');
}
</script>
</head>
@@ -866,6 +866,20 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be
//============================================================
+ // File starting with comment
+ reset_options();
+ test_fragment(
+ '<!--sample comment -->\n' +
+ '\n' +
+ '<html>\n' +
+ '<body>\n' +
+ ' <span>a span</span>\n' +
+ '</body>\n' +
+ '\n' +
+ '</html>');
+
+
+ //============================================================
// Php formatting
reset_options();
test_fragment('<h1 class="content-page-header"><?=$view["name"]; ?></h1>', '<h1 class="content-page-header">\n <?=$view["name"]; ?>\n</h1>');
@@ -712,6 +712,23 @@ exports.test_data = {
{ fragment: true, unchanged: '<div class="searchform"><input type="text" value="" name="s" id="s"><input type="submit" id="searchsubmit" value="Search"></div>' },
]
}, {
+ name: "File starting with comment",
+ description: "Unformatted tag behavior",
+ options: [],
+ tests: [{
+ fragment: true,
+ unchanged: [
+ '<!--sample comment -->',
+ '',
+ '<html>',
+ '<body>',
+ ' <span>a span</span>',
+ '</body>',
+ '',
+ '</html>'
+ ]
+ }, ]
+ }, {
name: "Php formatting",
description: "Php (<?php ... ?>) treated as comments.",
options: [],

0 comments on commit d2f8025

Please sign in to comment.