From 5abd3506d585245a7d8febff7f59ce1a68eea042 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Sat, 17 Dec 2016 20:10:15 -0800 Subject: [PATCH] Removed treatment of html-comment as non-html This is a UI only change but added a test to guard the engine. Fixed #1068 --- index.html | 5 +---- js/test/generated/beautify-html-tests.js | 14 ++++++++++++++ test/data/html/tests.js | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 3e1adaef1..02b8b31f9 100644 --- a/index.html +++ b/index.html @@ -300,11 +300,8 @@ function looks_like_html(source) { // - looks like html - // - 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) === '<'); } diff --git a/js/test/generated/beautify-html-tests.js b/js/test/generated/beautify-html-tests.js index e988f6627..dcc306b0e 100644 --- a/js/test/generated/beautify-html-tests.js +++ b/js/test/generated/beautify-html-tests.js @@ -865,6 +865,20 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('
'); + //============================================================ + // File starting with comment + reset_options(); + test_fragment( + '\n' + + '\n' + + '\n' + + '\n' + + ' a span\n' + + '\n' + + '\n' + + ''); + + //============================================================ // Php formatting reset_options(); diff --git a/test/data/html/tests.js b/test/data/html/tests.js index de823c886..9ca9ffe94 100644 --- a/test/data/html/tests.js +++ b/test/data/html/tests.js @@ -711,6 +711,23 @@ exports.test_data = { { fragment: true, unchanged: '
' }, { fragment: true, unchanged: '
' }, ] + }, { + name: "File starting with comment", + description: "Unformatted tag behavior", + options: [], + tests: [{ + fragment: true, + unchanged: [ + '', + '', + '', + '', + ' a span', + '', + '', + '' + ] + }, ] }, { name: "Php formatting", description: "Php () treated as comments.",