diff --git a/js/src/core/options.js b/js/src/core/options.js index 40dd330bd..27e0123c6 100644 --- a/js/src/core/options.js +++ b/js/src/core/options.js @@ -46,10 +46,20 @@ function Options(options, merge_child_field) { this.max_preserve_newlines = 0; } - this.indent_with_tabs = this._get_boolean('indent_with_tabs'); + this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t'); if (this.indent_with_tabs) { this.indent_char = '\t'; - this.indent_size = 1; + + // indent_size behavior changed after 1.8.6 + // It used to be that indent_size would be + // set to 1 for indent_with_tabs. That is no longer needed and + // actually doesn't make sense - why not use spaces? Further, + // that might produce unexpected behavior - tabs being used + // for single-column alignment. So, when indent_with_tabs is true + // and indent_size is 1, reset indent_size to 4. + if (this.indent_size === 1) { + this.indent_size = 4; + } } // Backwards compat with 1.3.x diff --git a/js/src/core/output.js b/js/src/core/output.js index 5e400ffb9..e01ffafeb 100644 --- a/js/src/core/output.js +++ b/js/src/core/output.js @@ -1,6 +1,5 @@ /*jshint node:true */ /* - The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. @@ -58,7 +57,7 @@ OutputLine.prototype.has_match = function(pattern) { OutputLine.prototype.set_indent = function(indent, alignment) { this.__indent_count = indent || 0; this.__alignment_count = alignment || 0; - this.__character_count = this.__parent.baseIndentLength + this.__alignment_count + this.__indent_count * this.__parent.indent_length; + this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count); }; OutputLine.prototype.get_character_count = function() { @@ -102,7 +101,7 @@ OutputLine.prototype.pop = function() { OutputLine.prototype.remove_indent = function() { if (this.__indent_count > 0) { this.__indent_count -= 1; - this.__character_count -= this.__parent.indent_length; + this.__character_count -= this.__parent.indent_size; } }; @@ -116,53 +115,81 @@ OutputLine.prototype.trim = function() { OutputLine.prototype.toString = function() { var result = ''; if (!this.is_empty()) { - if (this.__indent_count >= 0) { - result = this.__parent.get_indent_string(this.__indent_count); - } - if (this.__alignment_count >= 0) { - result += this.__parent.get_alignment_string(this.__alignment_count); - } + result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count); result += this.__items.join(''); } return result; }; -function IndentCache(base_string, level_string) { - this.__cache = [base_string]; - this.__level_string = level_string; +function IndentStringCache(options, baseIndentString) { + this.__cache = ['']; + this.__indent_size = options.indent_size; + this.__indent_string = options.indent_char; + if (!options.indent_with_tabs) { + this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char); + } + + // Set to null to continue support for auto detection of base indent + baseIndentString = baseIndentString || ''; + if (options.indent_level > 0) { + baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string); + } + + this.__base_string = baseIndentString; + this.__base_string_length = baseIndentString.length; } -IndentCache.prototype.__ensure_cache = function(level) { - while (level >= this.__cache.length) { - this.__cache.push(this.__cache[this.__cache.length - 1] + this.__level_string); +IndentStringCache.prototype.get_indent_size = function(indent, column) { + var result = this.__base_string_length; + column = column || 0; + if (indent < 0) { + result = 0; } + result += indent * this.__indent_size; + result += column; + return result; }; -IndentCache.prototype.get_level_string = function(level) { - this.__ensure_cache(level); - return this.__cache[level]; +IndentStringCache.prototype.get_indent_string = function(indent_level, column) { + var result = this.__base_string; + column = column || 0; + if (indent_level < 0) { + indent_level = 0; + result = ''; + } + column += indent_level * this.__indent_size; + this.__ensure_cache(column); + result += this.__cache[column]; + return result; }; - -function Output(options, baseIndentString) { - var indent_string = options.indent_char; - if (options.indent_size > 1) { - indent_string = new Array(options.indent_size + 1).join(options.indent_char); +IndentStringCache.prototype.__ensure_cache = function(column) { + while (column >= this.__cache.length) { + this.__add_column(); } +}; - // Set to null to continue support for auto detection of base indent level. - baseIndentString = baseIndentString || ''; - if (options.indent_level > 0) { - baseIndentString = new Array(options.indent_level + 1).join(indent_string); +IndentStringCache.prototype.__add_column = function() { + var column = this.__cache.length; + var indent = 0; + var result = ''; + if (this.__indent_size && column >= this.__indent_size) { + indent = Math.floor(column / this.__indent_size); + column -= indent * this.__indent_size; + result = new Array(indent + 1).join(this.__indent_string); } + if (column) { + result += new Array(column + 1).join(' '); + } + + this.__cache.push(result); +}; - this.__indent_cache = new IndentCache(baseIndentString, indent_string); - this.__alignment_cache = new IndentCache('', ' '); - this.baseIndentLength = baseIndentString.length; - this.indent_length = indent_string.length; +function Output(options, baseIndentString) { + this.__indent_cache = new IndentStringCache(options, baseIndentString); this.raw = false; this._end_with_newline = options.end_with_newline; - + this.indent_size = options.indent_size; this.__lines = []; this.previous_line = null; this.current_line = null; @@ -181,12 +208,12 @@ Output.prototype.get_line_number = function() { return this.__lines.length; }; -Output.prototype.get_indent_string = function(level) { - return this.__indent_cache.get_level_string(level); +Output.prototype.get_indent_string = function(indent, column) { + return this.__indent_cache.get_indent_string(indent, column); }; -Output.prototype.get_alignment_string = function(level) { - return this.__alignment_cache.get_level_string(level); +Output.prototype.get_indent_size = function(indent, column) { + return this.__indent_cache.get_indent_size(indent, column); }; Output.prototype.is_empty = function() { @@ -219,7 +246,6 @@ Output.prototype.get_code = function(eol) { if (eol !== '\n') { sweet_code = sweet_code.replace(/[\n]/g, eol); } - return sweet_code; }; diff --git a/js/src/html/beautifier.js b/js/src/html/beautifier.js index 2944d8df5..92498d3b1 100644 --- a/js/src/html/beautifier.js +++ b/js/src/html/beautifier.js @@ -482,7 +482,6 @@ Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_to parser_token.alignment_size = raw_token.text.length + 1; } - if (!parser_token.tag_complete && !parser_token.is_unformatted) { printer.alignment_size = parser_token.alignment_size; } diff --git a/js/src/javascript/beautifier.js b/js/src/javascript/beautifier.js index c42de4cb1..566896eae 100644 --- a/js/src/javascript/beautifier.js +++ b/js/src/javascript/beautifier.js @@ -191,6 +191,7 @@ Beautifier.prototype.create_flags = function(flags_base, mode) { in_case: false, // we're on the exact line with "case 0:" case_body: false, // the indented case-action block indentation_level: next_indent_level, + alignment: 0, line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level, start_line_index: this._output.get_line_number(), ternary_depth: 0 @@ -393,7 +394,7 @@ Beautifier.prototype.print_token_line_indentation = function(current_token) { if (this._options.keep_array_indentation && is_array(this._flags.mode) && current_token.newlines) { this._output.current_line.push(current_token.whitespace_before); this._output.space_before_token = false; - } else if (this._output.set_indent(this._flags.indentation_level)) { + } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) { this._flags.line_indent_level = this._flags.indentation_level; } } @@ -1343,29 +1344,40 @@ Beautifier.prototype.handle_block_comment = function(current_token, preserve_sta // block comment starts with a new line this.print_newline(false, preserve_statement_flags); - if (lines.length > 1) { - javadoc = all_lines_start_with(lines.slice(1), '*'); - starless = each_line_matches_indent(lines.slice(1), lastIndent); - } // first line always indented this.print_token(current_token, lines[0]); - for (j = 1; j < lines.length; j++) { - this.print_newline(false, true); + + + if (lines.length > 1) { + lines = lines.slice(1); + javadoc = all_lines_start_with(lines, '*'); + starless = each_line_matches_indent(lines, lastIndent); + if (javadoc) { - // javadoc: reformat and re-indent - this.print_token(current_token, ' ' + ltrim(lines[j])); - } else if (starless && lines[j].length > lastIndentLength) { - // starless: re-indent non-empty content, avoiding trim - this.print_token(current_token, lines[j].substring(lastIndentLength)); - } else { - // normal comments output raw - this._output.add_token(lines[j]); + this._flags.alignment = 1; } + + for (j = 0; j < lines.length; j++) { + this.print_newline(false, true); + if (javadoc) { + // javadoc: reformat and re-indent + this.print_token(current_token, ltrim(lines[j])); + } else if (starless && lines[j]) { + // starless: re-indent non-empty content, avoiding trim + this.print_token(current_token, lines[j].substring(lastIndentLength)); + } else { + // normal comments output raw + this._output.add_token(lines[j]); + } + } + + this._flags.alignment = 0; } - // for comments of more than one line, make sure there's a new line after + // for comments on their own line or more than one line, make sure there's a new line after this.print_newline(false, preserve_statement_flags); + }; Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) { diff --git a/js/test/generated/beautify-html-tests.js b/js/test/generated/beautify-html-tests.js index 32c9df92d..030e0d7a5 100644 --- a/js/test/generated/beautify-html-tests.js +++ b/js/test/generated/beautify-html-tests.js @@ -124,8 +124,9 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be success = success && test_fragment(input, expectation); if (opts.indent_size === 4 && input) { - wrapped_input = '
\n' + input.replace(/^(.+)$/mg, ' $1') + '\n inline\n
'; - wrapped_expectation = '
\n' + expectation.replace(/^(.+)$/mg, ' $1') + '\n inline\n
'; + var indent_string = opts.indent_with_tabs ? '\t' : ' '; + wrapped_input = '
\n' + input.replace(/^(.+)$/mg, indent_string + '$1') + '\n' + indent_string + 'inline\n
'; + wrapped_expectation = '
\n' + expectation.replace(/^(.+)$/mg, indent_string + '$1') + '\n' + indent_string + 'inline\n
'; success = success && test_fragment(wrapped_input, wrapped_expectation); } return success; @@ -532,9 +533,9 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be //============================================================ - // Attribute Wrap alignment with spaces - (wrap_attributes = ""force-aligned"", indent_with_tabs = "true") + // Attribute Wrap alignment with spaces and tabs - (wrap_attributes = ""force-aligned"", indent_with_tabs = "true") reset_options(); - set_name('Attribute Wrap alignment with spaces - (wrap_attributes = ""force-aligned"", indent_with_tabs = "true")'); + set_name('Attribute Wrap alignment with spaces and tabs - (wrap_attributes = ""force-aligned"", indent_with_tabs = "true")'); opts.wrap_attributes = 'force-aligned'; opts.indent_with_tabs = true; test_fragment( @@ -542,29 +543,76 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // -- output -- '
\n' + '\t
\n' + + '\t\t b="2">\n' + '\t\t
test
\n' + '\t
\n' + '
'); test_fragment( ''); + '\t name="garage"\n' + + '\t id="garage-02"\n' + + '\t class="ns-e-togg__radio ns-js-form-binding"\n' + + '\t value="02"\n' + + '\t {{#ifCond data.antragsart "05"}}\n' + + '\t checked="checked"\n' + + '\t {{/ifCond}}>'); test_fragment( '
\n' + '\t\n' + + '\t\t name="garage"\n' + + '\t\t id="garage-02"\n' + + '\t\t class="ns-e-togg__radio ns-js-form-binding"\n' + + '\t\t value="02"\n' + + '\t\t {{#ifCond data.antragsart "05"}}\n' + + '\t\t checked="checked"\n' + + '\t\t {{/ifCond}}>\n' + + '
'); + test_fragment( + '---\n' + + 'layout: mainLayout.html\n' + + 'page: default.html\n' + + '---\n' + + '\n' + + '
\n' + + '\t{{> componentXYZ my.data.key}}\n' + + '\t{{> componentABC my.other.data.key}}\n' + + '\tHello World\n' + + '\t

Your paragraph

\n' + + '
'); + + // Attribute Wrap alignment with spaces and tabs - (wrap_attributes = ""force"", indent_with_tabs = "true") + reset_options(); + set_name('Attribute Wrap alignment with spaces and tabs - (wrap_attributes = ""force"", indent_with_tabs = "true")'); + opts.wrap_attributes = 'force'; + opts.indent_with_tabs = true; + test_fragment( + '
test
', + // -- output -- + '
\n' + + '\t
\n' + + '\t\t
test
\n' + + '\t
\n' + + '
'); + test_fragment( + ''); + test_fragment( + '
\n' + + '\t\n' + '
'); test_fragment( '---\n' + @@ -651,7 +699,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( '
This is some text
', @@ -754,10 +802,10 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // Issue 1222 -- P tags are formatting correctly test_fragment( - '

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

', + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', // -- output -- '

Our forms for collecting address-related information follow a standard\n' + - ' design. Specific input elements will vary according to the form’s audience\n' + + ' design. Specific input elements willl vary according to the form’s audience\n' + ' and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( @@ -832,7 +880,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( '
This is some text
', @@ -936,10 +984,10 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // Issue 1222 -- P tags are formatting correctly test_fragment( - '

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

', + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', // -- output -- '

Our forms for collecting address-related information follow a standard\n' + - ' design. Specific input elements will vary according to the form’s audience\n' + + ' design. Specific input elements willl vary according to the form’s audience\n' + ' and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment('
This is some text
'); @@ -1027,10 +1075,10 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // Issue 1222 -- P tags are formatting correctly test_fragment( - '

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

', + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', // -- output -- '

Our forms for collecting address-related information follow a standard\n' + - ' design. Specific input elements will vary according to the form’s audience\n' + + ' design. Specific input elements willl vary according to the form’s audience\n' + ' and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment('
This is some text
'); @@ -1088,7 +1136,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment('
This is some text
'); test_fragment('
This is some text
'); @@ -1130,7 +1178,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( '
This is some text
', @@ -1233,10 +1281,10 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // Issue 1222 -- P tags are formatting correctly test_fragment( - '

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

', + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', // -- output -- '

Our forms for collecting address-related information follow a standard\n' + - ' design. Specific input elements will vary according to the form’s audience\n' + + ' design. Specific input elements willl vary according to the form’s audience\n' + ' and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( @@ -1340,10 +1388,10 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // Issue 1222 -- P tags are formatting correctly test_fragment( - '

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

', + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', // -- output -- '

Our forms for collecting address-related information follow a standard\n' + - ' design. Specific input elements will vary according to the form’s audience\n' + + ' design. Specific input elements willl vary according to the form’s audience\n' + ' and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment('
This is some text
'); @@ -1400,7 +1448,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment('
This is some text
'); test_fragment('
This is some text
'); @@ -1443,7 +1491,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( '
This is some text
', @@ -1517,7 +1565,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( '
This is some text
', @@ -1635,10 +1683,10 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be // Issue 1222 -- P tags are formatting correctly test_fragment( - '

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

', + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', // -- output -- '

Our forms for collecting address-related information follow a standard\n' + - ' design. Specific input elements will vary according to the form’s audience\n' + + ' design. Specific input elements willl vary according to the form’s audience\n' + ' and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( @@ -1727,7 +1775,7 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); // Issue 1222 -- P tags are formatting correctly - test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements will vary according to the form’s audience and purpose.

'); + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); bth('
This is some text
', '
This is some text
'); test_fragment( '
This is some text
', @@ -1792,6 +1840,306 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be ' type="text/css"\n' + '>'); + // Attribute Wrap - (wrap_attributes = ""force-expand-multiline"", wrap_attributes_indent_size = "4", indent_with_tabs = "true") + reset_options(); + set_name('Attribute Wrap - (wrap_attributes = ""force-expand-multiline"", wrap_attributes_indent_size = "4", indent_with_tabs = "true")'); + opts.wrap_attributes = 'force-expand-multiline'; + opts.wrap_attributes_indent_size = 4; + opts.indent_with_tabs = true; + bth('
This is some text
', '
This is some text
'); + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014\t0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + + // issue #869 + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + + // TODO: This is wrong - goes over line length but respects   + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010   0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010   0015 0016 0017 0018 0019 0020'); + + // issue #1496 - respect unicode non-breaking space + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic 0013 0014' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic 0013 0014' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); + + // TODO: This is wrong - goes over line length but respects unicode nbsp + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); + + // Issue 1222 -- P tags are formatting correctly + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); + bth('
This is some text
', '
This is some text
'); + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '', + // -- output -- + ''); + test_fragment( + '', + // -- output -- + '\n' + + ''); + + // Issue #1094 - Beautify correctly without quotes and with extra spaces + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '', + // -- output -- + '\n' + + ''); + test_fragment( + '', + // -- output -- + ''); + + // Attribute Wrap - (wrap_attributes = ""force-expand-multiline"", wrap_attributes_indent_size = "7", indent_with_tabs = "true") + reset_options(); + set_name('Attribute Wrap - (wrap_attributes = ""force-expand-multiline"", wrap_attributes_indent_size = "7", indent_with_tabs = "true")'); + opts.wrap_attributes = 'force-expand-multiline'; + opts.wrap_attributes_indent_size = 7; + opts.indent_with_tabs = true; + bth('
This is some text
', '
This is some text
'); + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014\t0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + + // issue #869 + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020'); + + // TODO: This is wrong - goes over line length but respects   + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010   0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010   0015 0016 0017 0018 0019 0020'); + + // issue #1496 - respect unicode non-breaking space + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic 0013 0014' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic 0013 0014' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); + + // TODO: This is wrong - goes over line length but respects unicode nbsp + test_fragment('0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); + + // Issue 1222 -- P tags are formatting correctly + test_fragment('

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

'); + bth('
This is some text
', '
This is some text
'); + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '', + // -- output -- + ''); + test_fragment( + '', + // -- output -- + '\n' + + ''); + + // Issue #1094 - Beautify correctly without quotes and with extra spaces + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '', + // -- output -- + '\n' + + ''); + test_fragment( + '', + // -- output -- + ''); + + // Attribute Wrap - (wrap_attributes = ""force-expand-multiline"", wrap_line_length = "80", indent_with_tabs = "true") + reset_options(); + set_name('Attribute Wrap - (wrap_attributes = ""force-expand-multiline"", wrap_line_length = "80", indent_with_tabs = "true")'); + opts.wrap_attributes = 'force-expand-multiline'; + opts.wrap_line_length = 80; + opts.indent_with_tabs = true; + bth('
This is some text
', '
This is some text
'); + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014\n' + + '\t0015 0016 0017 0018 0019 0020'); + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014\n' + + '\t0015 0016 0017 0018 0019 0020'); + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014\t0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014\n' + + '\t0015 0016 0017 0018 0019 0020'); + + // issue #869 + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013\n' + + '\t0014 0015 0016 0017 0018 0019 0020'); + + // TODO: This is wrong - goes over line length but respects   + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010   0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010   0015\n' + + '\t0016 0017 0018 0019 0020'); + + // issue #1496 - respect unicode non-breaking space + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic 0013 0014' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic 0013\n' + + '\t0014' + unicode_char(160) + '0015 0016 0017 0018 0019 0020'); + + // TODO: This is wrong - goes over line length but respects unicode nbsp + test_fragment( + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015 0016 0017 0018 0019 0020', + // -- output -- + '0 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 unic ' + unicode_char(160) + '' + unicode_char(160) + '0015\n' + + '\t0016 0017 0018 0019 0020'); + + // Issue 1222 -- P tags are formatting correctly + test_fragment( + '

Our forms for collecting address-related information follow a standard design. Specific input elements willl vary according to the form’s audience and purpose.

', + // -- output -- + '

Our forms for collecting address-related information follow a standard\n' + + '\tdesign. Specific input elements willl vary according to the form’s audience\n' + + '\tand purpose.

'); + bth('
This is some text
', '
This is some text
'); + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '', + // -- output -- + ''); + test_fragment( + '', + // -- output -- + '\n' + + ''); + + // Issue #1094 - Beautify correctly without quotes and with extra spaces + test_fragment( + '
This is some text
', + // -- output -- + 'This is some text'); + test_fragment( + '', + // -- output -- + '\n' + + ''); + test_fragment( + '', + // -- output -- + ''); + //============================================================ // Issue #1335 --