From b6b84720d7dc1bcd9158f0c64c62f35826d701e1 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Fri, 29 Jun 2018 20:16:52 -0700 Subject: [PATCH] Removing complex is_unformatted check --- js/lib/beautify-html.js | 33 +++------------------------------ js/src/html/beautifier.js | 33 +++------------------------------ 2 files changed, 6 insertions(+), 60 deletions(-) diff --git a/js/lib/beautify-html.js b/js/lib/beautify-html.js index c126229c6..a7a22db87 100644 --- a/js/lib/beautify-html.js +++ b/js/lib/beautify-html.js @@ -706,10 +706,10 @@ function Beautifier(html_source, options, js_beautify, css_beautify) { this.indent_content = true; this.traverse_whitespace(); } - } else if (this.is_unformatted(tag_check, unformatted) || - this.is_unformatted(tag_check, content_unformatted)) { + } else if (this.Utils.in_array(tag_check, unformatted) || + this.Utils.in_array(tag_check, content_unformatted)) { // do not reformat the "unformatted" or "content_unformatted" tags - if (this.is_unformatted(tag_check, unformatted)) { + if (this.Utils.in_array(tag_check, unformatted)) { content = [this.input.slice(tag_start, this.pos)]; } comment = this.get_unformatted('', tag_complete); //...delegate to get_unformatted function @@ -923,33 +923,6 @@ function Beautifier(html_source, options, js_beautify, css_beautify) { return Array(level + 1).join(this.indent_string); }; - this.is_unformatted = function(tag_check, unformatted) { - //is this an HTML5 block-level link? - if (!this.Utils.in_array(tag_check, unformatted)) { - return false; - } - - if (tag_check.toLowerCase() !== 'a' || !this.Utils.in_array('a', unformatted)) { - return true; - } - - //at this point we have a tag; is its first child something we want to remain - //unformatted? - var next_tag = this.get_tag(true /* peek. */ ); - - // test next_tag to see if it is just html tag (no external content) - var tag = (next_tag.text).match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/); - - // if next_tag comes back but is not an isolated tag, then - // let's treat the 'a' tag as having content - // and respect the unformatted option - if (!tag || this.Utils.in_array(tag[1], unformatted)) { - return true; - } else { - return false; - } - }; - this.printer = function(js_source, indent_character, indent_size, wrap_line_length, brace_style) { //handles input/output and some other printing functions this.input = js_source || ''; //gets the input for the Parser diff --git a/js/src/html/beautifier.js b/js/src/html/beautifier.js index 210fa3f9f..b216f526f 100644 --- a/js/src/html/beautifier.js +++ b/js/src/html/beautifier.js @@ -557,10 +557,10 @@ function Beautifier(html_source, options, js_beautify, css_beautify) { this.indent_content = true; this.traverse_whitespace(); } - } else if (this.is_unformatted(tag_check, unformatted) || - this.is_unformatted(tag_check, content_unformatted)) { + } else if (this.Utils.in_array(tag_check, unformatted) || + this.Utils.in_array(tag_check, content_unformatted)) { // do not reformat the "unformatted" or "content_unformatted" tags - if (this.is_unformatted(tag_check, unformatted)) { + if (this.Utils.in_array(tag_check, unformatted)) { content = [this.input.slice(tag_start, this.pos)]; } comment = this.get_unformatted('', tag_complete); //...delegate to get_unformatted function @@ -774,33 +774,6 @@ function Beautifier(html_source, options, js_beautify, css_beautify) { return Array(level + 1).join(this.indent_string); }; - this.is_unformatted = function(tag_check, unformatted) { - //is this an HTML5 block-level link? - if (!this.Utils.in_array(tag_check, unformatted)) { - return false; - } - - if (tag_check.toLowerCase() !== 'a' || !this.Utils.in_array('a', unformatted)) { - return true; - } - - //at this point we have a tag; is its first child something we want to remain - //unformatted? - var next_tag = this.get_tag(true /* peek. */ ); - - // test next_tag to see if it is just html tag (no external content) - var tag = (next_tag.text).match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/); - - // if next_tag comes back but is not an isolated tag, then - // let's treat the 'a' tag as having content - // and respect the unformatted option - if (!tag || this.Utils.in_array(tag[1], unformatted)) { - return true; - } else { - return false; - } - }; - this.printer = function(js_source, indent_character, indent_size, wrap_line_length, brace_style) { //handles input/output and some other printing functions this.input = js_source || ''; //gets the input for the Parser