/* AUTO-GENERATED. DO NOT MODIFY. */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Style HTML --------------- Written by Nochum Sossonko, (nsossonko@hotmail.com) Based on code initially developed by: Einar Lielmanis, https://beautifier.io/ Usage: style_html(html_source); style_html(html_source, options); The options are: indent_inner_html (default false) — indent and sections, indent_size (default 4) — indentation size, indent_char (default space) — character to indent with, wrap_line_length (default 250) - maximum amount of characters per line (0 = disable) brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none" put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are. inline (defaults to inline tags) - list of tags to be considered inline tags unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted content_unformatted (defaults to ["pre", "textarea"] tags) - list of tags, whose content shouldn't be reformatted indent_scripts (default normal) - "keep"|"separate"|"normal" preserve_newlines (default true) - whether existing line breaks before elements should be preserved Only works before elements, not inside tags or for text. max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}} end_with_newline (false) - end with a newline extra_liners (default [head,body,/html]) -List of tags that should have an extra newline before them. e.g. style_html(html_source, { 'indent_inner_html': false, 'indent_size': 2, 'indent_char': ' ', 'wrap_line_length': 78, 'brace_style': 'expand', 'preserve_newlines': true, 'max_preserve_newlines': 5, 'indent_handlebars': false, 'extra_liners': ['/html'] }); */ (function() { /* GENERATED_BUILD_OUTPUT */ var legacy_beautify_html = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 15); /******/ }) /************************************************************************/ /******/ ([ /* 0 */, /* 1 */, /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function OutputLine(parent) { this.__parent = parent; this.__character_count = 0; // use indent_count as a marker for this.__lines that have preserved indentation this.__indent_count = -1; this.__alignment_count = 0; this.__items = []; } OutputLine.prototype.item = function(index) { if (index < 0) { return this.__items[this.__items.length + index]; } else { return this.__items[index]; } }; OutputLine.prototype.has_match = function(pattern) { for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) { if (this.__items[lastCheckedOutput].match(pattern)) { return true; } } return false; }; 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; }; OutputLine.prototype.get_character_count = function() { return this.__character_count; }; OutputLine.prototype.is_empty = function() { return this.__items.length === 0; }; OutputLine.prototype.last = function() { if (!this.is_empty()) { return this.__items[this.__items.length - 1]; } else { return null; } }; OutputLine.prototype.push = function(item) { this.__items.push(item); this.__character_count += item.length; }; OutputLine.prototype.push_raw = function(item) { this.push(item); var last_newline_index = item.lastIndexOf('\n'); if (last_newline_index !== -1) { this.__character_count = item.length - last_newline_index; } }; OutputLine.prototype.pop = function() { var item = null; if (!this.is_empty()) { item = this.__items.pop(); this.__character_count -= item.length; } return item; }; OutputLine.prototype.remove_indent = function() { if (this.__indent_count > 0) { this.__indent_count -= 1; this.__character_count -= this.__parent.indent_length; } }; OutputLine.prototype.trim = function() { while (this.last() === ' ') { this.__items.pop(); this.__character_count -= 1; } }; 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.__items.join(''); } return result; }; function IndentCache(base_string, level_string) { this.__cache = [base_string]; this.__level_string = level_string; } IndentCache.prototype.__ensure_cache = function(level) { while (level >= this.__cache.length) { this.__cache.push(this.__cache[this.__cache.length - 1] + this.__level_string); } }; IndentCache.prototype.get_level_string = function(level) { this.__ensure_cache(level); return this.__cache[level]; }; 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); } // 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); } this.__indent_cache = new IndentCache(baseIndentString, indent_string); this.__alignment_cache = new IndentCache('', ' '); this.baseIndentLength = baseIndentString.length; this.indent_length = indent_string.length; this.raw = false; this._end_with_newline = options.end_with_newline; this.__lines = []; this.previous_line = null; this.current_line = null; this.space_before_token = false; // initialize this.__add_outputline(); } Output.prototype.__add_outputline = function() { this.previous_line = this.current_line; this.current_line = new OutputLine(this); this.__lines.push(this.current_line); }; 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_alignment_string = function(level) { return this.__alignment_cache.get_level_string(level); }; Output.prototype.is_empty = function() { return !this.previous_line && this.current_line.is_empty(); }; Output.prototype.add_new_line = function(force_newline) { // never newline at the start of file // otherwise, newline only if we didn't just add one or we're forced if (this.is_empty() || (!force_newline && this.just_added_newline())) { return false; } // if raw output is enabled, don't print additional newlines, // but still return True as though you had if (!this.raw) { this.__add_outputline(); } return true; }; Output.prototype.get_code = function(eol) { var sweet_code = this.__lines.join('\n').replace(/[\r\n\t ]+$/, ''); if (this._end_with_newline) { sweet_code += '\n'; } if (eol !== '\n') { sweet_code = sweet_code.replace(/[\n]/g, eol); } return sweet_code; }; Output.prototype.set_indent = function(indent, alignment) { indent = indent || 0; alignment = alignment || 0; // Never indent your first output indent at the start of the file if (this.__lines.length > 1) { this.current_line.set_indent(indent, alignment); return true; } this.current_line.set_indent(); return false; }; Output.prototype.add_raw_token = function(token) { for (var x = 0; x < token.newlines; x++) { this.__add_outputline(); } this.current_line.push(token.whitespace_before); this.current_line.push_raw(token.text); this.space_before_token = false; }; Output.prototype.add_token = function(printable_token) { this.add_space_before_token(); this.current_line.push(printable_token); }; Output.prototype.add_space_before_token = function() { if (this.space_before_token && !this.just_added_newline()) { this.current_line.push(' '); } this.space_before_token = false; }; Output.prototype.remove_indent = function(index) { var output_length = this.__lines.length; while (index < output_length) { this.__lines[index].remove_indent(); index++; } }; Output.prototype.trim = function(eat_newlines) { eat_newlines = (eat_newlines === undefined) ? false : eat_newlines; this.current_line.trim(this.indent_string, this.baseIndentString); while (eat_newlines && this.__lines.length > 1 && this.current_line.is_empty()) { this.__lines.pop(); this.current_line = this.__lines[this.__lines.length - 1]; this.current_line.trim(); } this.previous_line = this.__lines.length > 1 ? this.__lines[this.__lines.length - 2] : null; }; Output.prototype.just_added_newline = function() { return this.current_line.is_empty(); }; Output.prototype.just_added_blankline = function() { return this.is_empty() || (this.current_line.is_empty() && this.previous_line.is_empty()); }; Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) { var index = this.__lines.length - 2; while (index >= 0) { var potentialEmptyLine = this.__lines[index]; if (potentialEmptyLine.is_empty()) { break; } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 && potentialEmptyLine.item(-1) !== ends_with) { this.__lines.splice(index + 1, 0, new OutputLine(this)); this.previous_line = this.__lines[this.__lines.length - 2]; break; } index--; } }; module.exports.Output = Output; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function Token(type, text, newlines, whitespace_before) { this.type = type; this.text = text; // comments_before are // comments that have a new line before them // and may or may not have a newline after // this is a set of comments before this.comments_before = null; /* inline comment*/ // this.comments_after = new TokenStream(); // no new line before and newline after this.newlines = newlines || 0; this.whitespace_before = whitespace_before || ''; this.parent = null; this.next = null; this.previous = null; this.opened = null; this.closed = null; this.directives = null; } module.exports.Token = Token; /***/ }), /* 4 */, /* 5 */, /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function Options(options, merge_child_field) { options = _mergeOpts(options, merge_child_field); this.raw_options = _normalizeOpts(options); // Support passing the source text back with no change this.disabled = this._get_boolean('disabled'); this.eol = this._get_characters('eol', 'auto'); this.end_with_newline = this._get_boolean('end_with_newline'); this.indent_size = this._get_number('indent_size', 4); this.indent_char = this._get_characters('indent_char', ' '); this.indent_level = this._get_number('indent_level'); this.preserve_newlines = this._get_boolean('preserve_newlines', true); this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786); if (!this.preserve_newlines) { this.max_preserve_newlines = 0; } this.indent_with_tabs = this._get_boolean('indent_with_tabs'); if (this.indent_with_tabs) { this.indent_char = '\t'; this.indent_size = 1; } // Backwards compat with 1.3.x this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char')); } Options.prototype._get_array = function(name, default_value) { var option_value = this.raw_options[name]; var result = default_value || []; if (typeof option_value === 'object') { if (option_value !== null && typeof option_value.concat === 'function') { result = option_value.concat(); } } else if (typeof option_value === 'string') { result = option_value.split(/[^a-zA-Z0-9_\/\-]+/); } return result; }; Options.prototype._get_boolean = function(name, default_value) { var option_value = this.raw_options[name]; var result = option_value === undefined ? !!default_value : !!option_value; return result; }; Options.prototype._get_characters = function(name, default_value) { var option_value = this.raw_options[name]; var result = default_value || ''; if (typeof option_value === 'string') { result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t'); } return result; }; Options.prototype._get_number = function(name, default_value) { var option_value = this.raw_options[name]; default_value = parseInt(default_value, 10); if (isNaN(default_value)) { default_value = 0; } var result = parseInt(option_value, 10); if (isNaN(result)) { result = default_value; } return result; }; Options.prototype._get_selection = function(name, selection_list, default_value) { var result = this._get_selection_list(name, selection_list, default_value); if (result.length !== 1) { throw new Error( "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"); } return result[0]; }; Options.prototype._get_selection_list = function(name, selection_list, default_value) { if (!selection_list || selection_list.length === 0) { throw new Error("Selection list cannot be empty."); } default_value = default_value || [selection_list[0]]; if (!this._is_valid_selection(default_value, selection_list)) { throw new Error("Invalid Default Value!"); } var result = this._get_array(name, default_value); if (!this._is_valid_selection(result, selection_list)) { throw new Error( "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"); } return result; }; Options.prototype._is_valid_selection = function(result, selection_list) { return result.length && selection_list.length && !result.some(function(item) { return selection_list.indexOf(item) === -1; }); }; // merges child options up with the parent options object // Example: obj = {a: 1, b: {a: 2}} // mergeOpts(obj, 'b') // // Returns: {a: 2, b: {a: 2}} function _mergeOpts(allOptions, childFieldName) { var finalOpts = {}; allOptions = allOptions || {}; var name; for (name in allOptions) { if (name !== childFieldName) { finalOpts[name] = allOptions[name]; } } //merge in the per type settings for the childFieldName if (childFieldName && allOptions[childFieldName]) { for (name in allOptions[childFieldName]) { finalOpts[name] = allOptions[childFieldName][name]; } } return finalOpts; } function _normalizeOpts(options) { var convertedOpts = {}; var key; for (key in options) { var newKey = key.replace(/-/g, "_"); convertedOpts[newKey] = options[key]; } return convertedOpts; } module.exports.Options = Options; module.exports.normalizeOpts = _normalizeOpts; module.exports.mergeOpts = _mergeOpts; /***/ }), /* 7 */, /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function InputScanner(input_string) { this.__input = input_string || ''; this.__input_length = this.__input.length; this.__position = 0; } InputScanner.prototype.restart = function() { this.__position = 0; }; InputScanner.prototype.back = function() { if (this.__position > 0) { this.__position -= 1; } }; InputScanner.prototype.hasNext = function() { return this.__position < this.__input_length; }; InputScanner.prototype.next = function() { var val = null; if (this.hasNext()) { val = this.__input.charAt(this.__position); this.__position += 1; } return val; }; InputScanner.prototype.peek = function(index) { var val = null; index = index || 0; index += this.__position; if (index >= 0 && index < this.__input_length) { val = this.__input.charAt(index); } return val; }; InputScanner.prototype.test = function(pattern, index) { index = index || 0; index += this.__position; pattern.lastIndex = index; if (index >= 0 && index < this.__input_length) { var pattern_match = pattern.exec(this.__input); return pattern_match && pattern_match.index === index; } else { return false; } }; InputScanner.prototype.testChar = function(pattern, index) { // test one character regex match var val = this.peek(index); return val !== null && pattern.test(val); }; InputScanner.prototype.match = function(pattern) { pattern.lastIndex = this.__position; var pattern_match = pattern.exec(this.__input); if (pattern_match && pattern_match.index === this.__position) { this.__position += pattern_match[0].length; } else { pattern_match = null; } return pattern_match; }; InputScanner.prototype.read = function(pattern) { var val = ''; var match = this.match(pattern); if (match) { val = match[0]; } return val; }; InputScanner.prototype.readUntil = function(pattern, include_match) { var val = ''; var match_index = this.__position; pattern.lastIndex = this.__position; var pattern_match = pattern.exec(this.__input); if (pattern_match) { if (include_match) { match_index = pattern_match.index + pattern_match[0].length; } else { match_index = pattern_match.index; } } else { match_index = this.__input_length; } val = this.__input.substring(this.__position, match_index); this.__position = match_index; return val; }; InputScanner.prototype.readUntilAfter = function(pattern) { return this.readUntil(pattern, true); }; /* css beautifier legacy helpers */ InputScanner.prototype.peekUntilAfter = function(pattern) { var start = this.__position; var val = this.readUntilAfter(pattern); this.__position = start; return val; }; InputScanner.prototype.lookBack = function(testVal) { var start = this.__position - 1; return start >= testVal.length && this.__input.substring(start - testVal.length, start) .toLowerCase() === testVal; }; module.exports.InputScanner = InputScanner; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var InputScanner = __webpack_require__(8).InputScanner; var Token = __webpack_require__(3).Token; var TokenStream = __webpack_require__(10).TokenStream; var TOKEN = { START: 'TK_START', RAW: 'TK_RAW', EOF: 'TK_EOF' }; var Tokenizer = function(input_string, options) { this._input = new InputScanner(input_string); this._options = options || {}; this.__tokens = null; this.__newline_count = 0; this.__whitespace_before_token = ''; this._whitespace_pattern = /[\n\r\t ]+/g; this._newline_pattern = /([^\n\r]*)(\r\n|[\n\r])?/g; }; Tokenizer.prototype.tokenize = function() { this._input.restart(); this.__tokens = new TokenStream(); this._reset(); var current; var previous = new Token(TOKEN.START, ''); var open_token = null; var open_stack = []; var comments = new TokenStream(); while (previous.type !== TOKEN.EOF) { current = this._get_next_token(previous, open_token); while (this._is_comment(current)) { comments.add(current); current = this._get_next_token(previous, open_token); } if (!comments.isEmpty()) { current.comments_before = comments; comments = new TokenStream(); } current.parent = open_token; if (this._is_opening(current)) { open_stack.push(open_token); open_token = current; } else if (open_token && this._is_closing(current, open_token)) { current.opened = open_token; open_token.closed = current; open_token = open_stack.pop(); current.parent = open_token; } current.previous = previous; previous.next = current; this.__tokens.add(current); previous = current; } return this.__tokens; }; Tokenizer.prototype._is_first_token = function() { return this.__tokens.isEmpty(); }; Tokenizer.prototype._reset = function() {}; Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false this._readWhitespace(); var resulting_string = this._input.read(/.+/g); if (resulting_string) { return this._create_token(TOKEN.RAW, resulting_string); } else { return this._create_token(TOKEN.EOF, ''); } }; Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false return false; }; Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false return false; }; Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false return false; }; Tokenizer.prototype._create_token = function(type, text) { var token = new Token(type, text, this.__newline_count, this.__whitespace_before_token); this.__newline_count = 0; this.__whitespace_before_token = ''; return token; }; Tokenizer.prototype._readWhitespace = function() { var resulting_string = this._input.read(this._whitespace_pattern); if (resulting_string === ' ') { this.__whitespace_before_token = resulting_string; } else if (resulting_string !== '') { this._newline_pattern.lastIndex = 0; var nextMatch = this._newline_pattern.exec(resulting_string); while (nextMatch[2]) { this.__newline_count += 1; nextMatch = this._newline_pattern.exec(resulting_string); } this.__whitespace_before_token = nextMatch[1]; } }; module.exports.Tokenizer = Tokenizer; module.exports.TOKEN = TOKEN; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function TokenStream(parent_token) { // private this.__tokens = []; this.__tokens_length = this.__tokens.length; this.__position = 0; this.__parent_token = parent_token; } TokenStream.prototype.restart = function() { this.__position = 0; }; TokenStream.prototype.isEmpty = function() { return this.__tokens_length === 0; }; TokenStream.prototype.hasNext = function() { return this.__position < this.__tokens_length; }; TokenStream.prototype.next = function() { var val = null; if (this.hasNext()) { val = this.__tokens[this.__position]; this.__position += 1; } return val; }; TokenStream.prototype.peek = function(index) { var val = null; index = index || 0; index += this.__position; if (index >= 0 && index < this.__tokens_length) { val = this.__tokens[index]; } return val; }; TokenStream.prototype.add = function(token) { if (this.__parent_token) { token.parent = this.__parent_token; } this.__tokens.push(token); this.__tokens_length += 1; }; module.exports.TokenStream = TokenStream; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ function Directives(start_block_pattern, end_block_pattern) { start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source; end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source; this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g'); this.__directive_pattern = / (\w+)[:](\w+)/g; this.__directives_end_ignore_pattern = new RegExp('(?:[\\s\\S]*?)((?:' + start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern + ')|$)', 'g'); } Directives.prototype.get_directives = function(text) { if (!text.match(this.__directives_block_pattern)) { return null; } var directives = {}; this.__directive_pattern.lastIndex = 0; var directive_match = this.__directive_pattern.exec(text); while (directive_match) { directives[directive_match[1]] = directive_match[2]; directive_match = this.__directive_pattern.exec(text); } return directives; }; Directives.prototype.readIgnored = function(input) { return input.read(this.__directives_end_ignore_pattern); }; module.exports.Directives = Directives; /***/ }), /* 12 */, /* 13 */, /* 14 */, /* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var Beautifier = __webpack_require__(16).Beautifier; function style_html(html_source, options, js_beautify, css_beautify) { var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify); return beautifier.beautify(); } module.exports = style_html; /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var Options = __webpack_require__(17).Options; var Output = __webpack_require__(2).Output; var Tokenizer = __webpack_require__(18).Tokenizer; var TOKEN = __webpack_require__(18).TOKEN; var lineBreak = /\r\n|[\r\n]/; var allLineBreaks = /\r\n|[\r\n]/g; var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions this.indent_level = 0; this.alignment_size = 0; this.wrap_line_length = options.wrap_line_length; this.max_preserve_newlines = options.max_preserve_newlines; this.preserve_newlines = options.preserve_newlines; this._output = new Output(options, base_indent_string); }; Printer.prototype.current_line_has_match = function(pattern) { return this._output.current_line.has_match(pattern); }; Printer.prototype.set_space_before_token = function(value) { this._output.space_before_token = value; }; Printer.prototype.add_raw_token = function(token) { this._output.add_raw_token(token); }; Printer.prototype.print_preserved_newlines = function(raw_token) { var newlines = 0; if (raw_token.type !== TOKEN.TEXT && raw_token.previous.type !== TOKEN.TEXT) { newlines = raw_token.newlines ? 1 : 0; } if (this.preserve_newlines) { newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1; } for (var n = 0; n < newlines; n++) { this.print_newline(n > 0); } return newlines !== 0; }; Printer.prototype.traverse_whitespace = function(raw_token) { if (raw_token.whitespace_before || raw_token.newlines) { if (!this.print_preserved_newlines(raw_token)) { this._output.space_before_token = true; this.print_space_or_wrap(raw_token.text); } return true; } return false; }; // Append a space to the given content (string array) or, if we are // at the wrap_line_length, append a newline/indentation. // return true if a newline was added, false if a space was added Printer.prototype.print_space_or_wrap = function(text) { if (this.wrap_line_length) { if (this._output.current_line.get_character_count() + text.length + 1 >= this.wrap_line_length) { //insert a line when the wrap_line_length is reached return this._output.add_new_line(); } } return false; }; Printer.prototype.print_newline = function(force) { this._output.add_new_line(force); }; Printer.prototype.print_token = function(text) { if (text) { if (this._output.current_line.is_empty()) { this._output.set_indent(this.indent_level, this.alignment_size); } this._output.add_token(text); } }; Printer.prototype.print_raw_text = function(text) { this._output.current_line.push_raw(text); }; Printer.prototype.indent = function() { this.indent_level++; }; Printer.prototype.unindent = function() { if (this.indent_level > 0) { this.indent_level--; } }; Printer.prototype.get_full_indent = function(level) { level = this.indent_level + (level || 0); if (level < 1) { return ''; } return this._output.get_indent_string(level); }; var uses_beautifier = function(tag_check, start_token) { var raw_token = start_token.next; if (!start_token.closed) { return false; } while (raw_token.type !== TOKEN.EOF && raw_token.closed !== start_token) { if (raw_token.type === TOKEN.ATTRIBUTE && raw_token.text === 'type') { // For script and style tags that have a type attribute, only enable custom beautifiers for matching values var peekEquals = raw_token.next ? raw_token.next : raw_token; var peekValue = peekEquals.next ? peekEquals.next : peekEquals; if (peekEquals.type === TOKEN.EQUALS && peekValue.type === TOKEN.VALUE) { return (tag_check === 'style' && peekValue.text.search('text/css') > -1) || (tag_check === 'script' && peekValue.text.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1); } return false; } raw_token = raw_token.next; } return true; }; function in_array(what, arr) { return arr.indexOf(what) !== -1; } function TagFrame(parent, parser_token, indent_level) { this.parent = parent || null; this.tag = parser_token ? parser_token.tag_name : ''; this.indent_level = indent_level || 0; this.parser_token = parser_token || null; } function TagStack(printer) { this._printer = printer; this._current_frame = null; } TagStack.prototype.get_parser_token = function() { return this._current_frame ? this._current_frame.parser_token : null; }; TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level); this._current_frame = new_frame; }; TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer var parser_token = null; if (frame) { parser_token = frame.parser_token; this._printer.indent_level = frame.indent_level; this._current_frame = frame.parent; } return parser_token; }; TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer var frame = this._current_frame; while (frame) { //till we reach '' (the initial value); if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it break; } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) { frame = null; break; } frame = frame.parent; } return frame; }; TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer var frame = this._get_frame([tag], stop_list); return this._try_pop_frame(frame); }; TagStack.prototype.indent_to_tag = function(tag_list) { var frame = this._get_frame(tag_list); if (frame) { this._printer.indent_level = frame.indent_level; } }; function Beautifier(source_text, options, js_beautify, css_beautify) { //Wrapper function to invoke all the necessary constructors and deal with the output. this._source_text = source_text || ''; options = options || {}; this._js_beautify = js_beautify; this._css_beautify = css_beautify; this._tag_stack = null; // Allow the setting of language/file-type specific options // with inheritance of overall settings var optionHtml = new Options(options, 'html'); this._options = optionHtml; this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force'; this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline'); this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned'); this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple'); } Beautifier.prototype.beautify = function() { // if disabled, return the input unchanged. if (this._options.disabled) { return this._source_text; } var source_text = this._source_text; var eol = this._options.eol; if (this._options.eol === 'auto') { eol = '\n'; if (source_text && lineBreak.test(source_text)) { eol = source_text.match(lineBreak)[0]; } } // HACK: newline parsing inconsistent. This brute force normalizes the input. source_text = source_text.replace(allLineBreaks, '\n'); var baseIndentString = ''; // Including commented out text would change existing html beautifier behavior to autodetect base indent. // baseIndentString = source_text.match(/^[\t ]*/)[0]; var last_token = { text: '', type: '' }; var last_tag_token = new TagOpenParserToken(); var printer = new Printer(this._options, baseIndentString); var tokens = new Tokenizer(source_text, this._options).tokenize(); this._tag_stack = new TagStack(printer); var parser_token = null; var raw_token = tokens.next(); while (raw_token.type !== TOKEN.EOF) { if (raw_token.type === TOKEN.TAG_OPEN || raw_token.type === TOKEN.COMMENT) { parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token); last_tag_token = parser_token; } else if ((raw_token.type === TOKEN.ATTRIBUTE || raw_token.type === TOKEN.EQUALS || raw_token.type === TOKEN.VALUE) || (raw_token.type === TOKEN.TEXT && !last_tag_token.tag_complete)) { parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens); } else if (raw_token.type === TOKEN.TAG_CLOSE) { parser_token = this._handle_tag_close(printer, raw_token, last_tag_token); } else if (raw_token.type === TOKEN.TEXT) { parser_token = this._handle_text(printer, raw_token, last_tag_token); } else { // This should never happen, but if it does. Print the raw token printer.add_raw_token(raw_token); } last_token = parser_token; raw_token = tokens.next(); } var sweet_code = printer._output.get_code(eol); return sweet_code; }; Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) { var parser_token = { text: raw_token.text, type: raw_token.type }; printer.alignment_size = 0; last_tag_token.tag_complete = true; printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== ''); if (last_tag_token.is_unformatted) { printer.add_raw_token(raw_token); } else { if (last_tag_token.tag_start_char === '<') { printer.set_space_before_token(raw_token.text[0] === '/'); // space before />, no space before > if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) { printer.print_newline(false); } } printer.print_token(raw_token.text); } if (last_tag_token.indent_content && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) { printer.indent(); // only indent once per opened tag last_tag_token.indent_content = false; } return parser_token; }; Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) { var parser_token = { text: raw_token.text, type: raw_token.type }; printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== ''); if (last_tag_token.is_unformatted) { printer.add_raw_token(raw_token); } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN.TEXT) { // For the insides of handlebars allow newlines or a single space between open and contents if (printer.print_preserved_newlines(raw_token)) { printer.print_raw_text(raw_token.whitespace_before + raw_token.text); } else { printer.print_token(raw_token.text); } } else { if (raw_token.type === TOKEN.ATTRIBUTE) { printer.set_space_before_token(true); last_tag_token.attr_count += 1; } else if (raw_token.type === TOKEN.EQUALS) { //no space before = printer.set_space_before_token(false); } else if (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) { //no space before value printer.set_space_before_token(false); } if (printer._output.space_before_token && last_tag_token.tag_start_char === '<') { var wrapped = printer.print_space_or_wrap(raw_token.text); if (raw_token.type === TOKEN.ATTRIBUTE) { var indentAttrs = wrapped && !this._is_wrap_attributes_force; if (this._is_wrap_attributes_force) { var force_first_attr_wrap = false; if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) { var is_only_attribute = true; var peek_index = 0; var peek_token; do { peek_token = tokens.peek(peek_index); if (peek_token.type === TOKEN.ATTRIBUTE) { is_only_attribute = false; break; } peek_index += 1; } while (peek_index < 4 && peek_token.type !== TOKEN.EOF && peek_token.type !== TOKEN.TAG_CLOSE); force_first_attr_wrap = !is_only_attribute; } if (last_tag_token.attr_count > 1 || force_first_attr_wrap) { printer.print_newline(false); indentAttrs = true; } } if (indentAttrs) { last_tag_token.has_wrapped_attrs = true; } } } printer.print_token(raw_token.text); } return parser_token; }; Beautifier.prototype._handle_text = function(printer, raw_token, last_tag_token) { var parser_token = { text: raw_token.text, type: 'TK_CONTENT' }; if (last_tag_token.custom_beautifier) { //check if we need to format javascript this._print_custom_beatifier_text(printer, raw_token, last_tag_token); } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) { printer.add_raw_token(raw_token); } else { printer.traverse_whitespace(raw_token); printer.print_token(raw_token.text); } return parser_token; }; Beautifier.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) { if (raw_token.text !== '') { printer.print_newline(false); var text = raw_token.text, _beautifier, script_indent_level = 1; if (last_tag_token.tag_name === 'script') { _beautifier = typeof this._js_beautify === 'function' && this._js_beautify; } else if (last_tag_token.tag_name === 'style') { _beautifier = typeof this._css_beautify === 'function' && this._css_beautify; } if (this._options.indent_scripts === "keep") { script_indent_level = 0; } else if (this._options.indent_scripts === "separate") { script_indent_level = -printer.indent_level; } var indentation = printer.get_full_indent(script_indent_level); // if there is at least one empty line at the end of this text, strip it // we'll be adding one back after the text but before the containing tag. text = text.replace(/\n[ \t]*$/, ''); if (_beautifier) { // call the Beautifier if avaliable var Child_options = function() { this.eol = '\n'; }; Child_options.prototype = this._options.raw_options; var child_options = new Child_options(); text = _beautifier(indentation + text, child_options); } else { // simply indent the string otherwise var white = text.match(/^\s*/)[0]; var _level = white.match(/[^\n\r]*$/)[0].split(this._options.indent_string).length - 1; var reindent = this._get_full_indent(script_indent_level - _level); text = (indentation + text.trim()) .replace(/\r\n|\r|\n/g, '\n' + reindent); } if (text) { printer.print_raw_text(text); printer.print_newline(true); } } }; Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) { var parser_token = this._get_tag_open_token(raw_token); if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) && raw_token.type === TOKEN.TAG_OPEN && raw_token.text.indexOf(']*)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; } else { tag_check_match = raw_token.text.match(/^{{\#?([^\s}]+)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; } this.tag_check = this.tag_check.toLowerCase(); if (raw_token.type === TOKEN.COMMENT) { this.tag_complete = true; } this.is_start_tag = this.tag_check.charAt(0) !== '/'; this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check; this.is_end_tag = !this.is_start_tag || (raw_token.closed && raw_token.closed.text === '/>'); // handlebars tags that don't start with # or ^ are single_tags, and so also start and end. this.is_end_tag = this.is_end_tag || (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2))))); } }; Beautifier.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token); parser_token.alignment_size = this._options.wrap_attributes_indent_size; parser_token.is_end_tag = parser_token.is_end_tag || in_array(parser_token.tag_check, this._options.void_elements); parser_token.is_empty_element = parser_token.tag_complete || (parser_token.is_start_tag && parser_token.is_end_tag); parser_token.is_unformatted = !parser_token.tag_complete && in_array(parser_token.tag_check, this._options.unformatted); parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array(parser_token.tag_check, this._options.content_unformatted); parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{'; return parser_token; }; Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) { if (!parser_token.is_empty_element) { if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors } else { // it's a start-tag // check if this tag is starting an element that has optional end element // and do an ending needed this._do_optional_end_element(parser_token); this._tag_stack.record_tag(parser_token); //push it on the tag stack if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') && !(parser_token.is_unformatted || parser_token.is_content_unformatted)) { parser_token.custom_beautifier = uses_beautifier(parser_token.tag_check, raw_token); } } } if (in_array(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line printer.print_newline(false); if (!printer._output.just_added_blankline()) { printer.print_newline(true); } } if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /) // if you hit an else case, reset the indent level if you are inside an: // 'if', 'unless', or 'each' block. if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') { this._tag_stack.indent_to_tag(['if', 'unless', 'each']); parser_token.indent_content = true; // Don't add a newline if opening {{#if}} tag is on the current line var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/); if (!foundIfOnCurrentLine) { printer.print_newline(false); } } // Don't add a newline before elements that should remain where they are. if (parser_token.tag_name === '!--' && last_token.type === TOKEN.TAG_CLOSE && last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) { //Do nothing. Leave comments on same line. } else if (!parser_token.is_inline_element && !parser_token.is_unformatted) { printer.print_newline(false); } } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) { if (!parser_token.is_inline_element && !parser_token.is_unformatted) { printer.print_newline(false); } } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) || !(parser_token.is_inline_element || (last_tag_token.is_inline_element) || (last_token.type === TOKEN.TAG_CLOSE && parser_token.start_tag_token === last_tag_token) || (last_token.type === 'TK_CONTENT') )) { printer.print_newline(false); } } else { // it's a start-tag parser_token.indent_content = !parser_token.custom_beautifier; if (parser_token.tag_start_char === '<') { if (parser_token.tag_name === 'html') { parser_token.indent_content = this._options.indent_inner_html; } else if (parser_token.tag_name === 'head') { parser_token.indent_content = this._options.indent_head_inner_html; } else if (parser_token.tag_name === 'body') { parser_token.indent_content = this._options.indent_body_inner_html; } } if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') { if (parser_token.parent) { parser_token.parent.multiline_content = true; } printer.print_newline(false); } } }; //To be used for

tag special case: //var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul']; Beautifier.prototype._do_optional_end_element = function(parser_token) { // NOTE: cases of "if there is no more content in the parent element" // are handled automatically by the beautifier. // It assumes parent or ancestor close tag closes all children. // https://www.w3.org/TR/html5/syntax.html#optional-tags if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) { return; } else if (parser_token.tag_name === 'body') { // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment. this._tag_stack.try_pop('head'); //} else if (parser_token.tag_name === 'body') { // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment. } else if (parser_token.tag_name === 'li') { // An li element’s end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element. this._tag_stack.try_pop('li', ['ol', 'ul']); } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') { // A dd element’s end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element. // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element. this._tag_stack.try_pop('dt', ['dl']); this._tag_stack.try_pop('dd', ['dl']); //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) { //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up. //A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element. //this._tag_stack.try_pop('p', ['body']); } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') { // An rt element’s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element. // An rp element’s end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element. this._tag_stack.try_pop('rt', ['ruby', 'rtc']); this._tag_stack.try_pop('rp', ['ruby', 'rtc']); } else if (parser_token.tag_name === 'optgroup') { // An optgroup element’s end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element. // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element. this._tag_stack.try_pop('optgroup', ['select']); //this._tag_stack.try_pop('option', ['select']); } else if (parser_token.tag_name === 'option') { // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element. this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']); } else if (parser_token.tag_name === 'colgroup') { // DONE: A colgroup element’s end tag may be omitted if the colgroup element is not immediately followed by a space character or a comment. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started. this._tag_stack.try_pop('caption', ['table']); } else if (parser_token.tag_name === 'thead') { // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started. this._tag_stack.try_pop('caption', ['table']); this._tag_stack.try_pop('colgroup', ['table']); //} else if (parser_token.tag_name === 'caption') { // DONE: A caption element’s end tag may be omitted if the caption element is not immediately followed by a space character or a comment. } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') { // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element. // A tbody element’s end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started. this._tag_stack.try_pop('caption', ['table']); this._tag_stack.try_pop('colgroup', ['table']); this._tag_stack.try_pop('thead', ['table']); this._tag_stack.try_pop('tbody', ['table']); //} else if (parser_token.tag_name === 'tfoot') { // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element. } else if (parser_token.tag_name === 'tr') { // A tr element’s end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element. // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started. // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started. this._tag_stack.try_pop('caption', ['table']); this._tag_stack.try_pop('colgroup', ['table']); this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']); } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') { // A td element’s end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element. // A th element’s end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element. this._tag_stack.try_pop('td', ['tr']); this._tag_stack.try_pop('th', ['tr']); } // Start element omission not handled currently // A head element’s start tag may be omitted if the element is empty, or if the first thing inside the head element is an element. // A tbody element’s start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can’t be omitted if the element is empty.) // A colgroup element’s start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can’t be omitted if the element is empty.) // Fix up the parent of the parser token parser_token.parent = this._tag_stack.get_parser_token(); }; module.exports.Beautifier = Beautifier; /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var BaseOptions = __webpack_require__(6).Options; function Options(options) { BaseOptions.call(this, options, 'html'); this.indent_inner_html = this._get_boolean('indent_inner_html'); this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true); this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true); this.indent_handlebars = this._get_boolean('indent_handlebars', true); this.wrap_attributes = this._get_selection('wrap_attributes', ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple']); this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size); this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']); this.inline = this._get_array('inline', [ // https://www.w3.org/TR/html5/dom.html#phrasing-content 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite', 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript', 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small', 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var', 'video', 'wbr', 'text', // prexisting - not sure of full effect of removing, leaving in 'acronym', 'address', 'big', 'dt', 'ins', 'strike', 'tt' ]); this.void_elements = this._get_array('void_elements', [ // HTLM void elements - aka self-closing tags - aka singletons // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr', // NOTE: Optional tags are too complex for a simple list // they are hard coded in _do_optional_end_element // Doctype and xml elements '!doctype', '?xml', // ?php and ?= tags '?php', '?=', // other tags that were in this list, keeping just in case 'basefont', 'isindex' ]); this.unformatted = this._get_array('unformatted', []); this.content_unformatted = this._get_array('content_unformatted', [ 'pre', 'textarea' ]); this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']); } Options.prototype = new BaseOptions(); module.exports.Options = Options; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*jshint node:true */ /* The MIT License (MIT) Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var BaseTokenizer = __webpack_require__(9).Tokenizer; var BASETOKEN = __webpack_require__(9).TOKEN; var Directives = __webpack_require__(11).Directives; var TOKEN = { TAG_OPEN: 'TK_TAG_OPEN', TAG_CLOSE: 'TK_TAG_CLOSE', ATTRIBUTE: 'TK_ATTRIBUTE', EQUALS: 'TK_EQUALS', VALUE: 'TK_VALUE', COMMENT: 'TK_COMMENT', TEXT: 'TK_TEXT', UNKNOWN: 'TK_UNKNOWN', START: BASETOKEN.START, RAW: BASETOKEN.RAW, EOF: BASETOKEN.EOF }; var directives_core = new Directives(/<\!--/, /-->/); var Tokenizer = function(input_string, options) { BaseTokenizer.call(this, input_string, options); this._current_tag_name = ''; // Words end at whitespace or when a tag starts // if we are indenting handlebars, they are considered tags this._word_pattern = this._options.indent_handlebars ? /[\n\r\t <]|{{/g : /[\n\r\t <]/g; }; Tokenizer.prototype = new BaseTokenizer(); Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN; }; Tokenizer.prototype._is_opening = function(current_token) { return current_token.type === TOKEN.TAG_OPEN; }; Tokenizer.prototype._is_closing = function(current_token, open_token) { return current_token.type === TOKEN.TAG_CLOSE && (open_token && ( ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') || (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{'))); }; Tokenizer.prototype._reset = function() { this._current_tag_name = ''; }; Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false this._readWhitespace(); var token = null; var c = this._input.peek(); if (c === null) { return this._create_token(TOKEN.EOF, ''); } token = token || this._read_attribute(c, previous_token, open_token); token = token || this._read_raw_content(previous_token, open_token); token = token || this._read_comment(c); token = token || this._read_open(c, open_token); token = token || this._read_close(c, open_token); token = token || this._read_content_word(); token = token || this._create_token(TOKEN.UNKNOWN, this._input.next()); return token; }; Tokenizer.prototype._read_comment = function(c) { // jshint unused:false var token = null; if (c === '<' || c === '{') { var peek1 = this._input.peek(1); var peek2 = this._input.peek(2); if ((c === '<' && (peek1 === '!' || peek1 === '?' || peek1 === '%')) || this._options.indent_handlebars && c === '{' && peek1 === '{' && peek2 === '!') { //if we're in a comment, do something special // We treat all comments as literals, even more than preformatted tags // we just look for the appropriate close tag // this is will have very poor perf, but will work for now. var comment = '', delimiter = '>', matched = false; var input_char = this._input.next(); while (input_char) { comment += input_char; // only need to check for the delimiter if the last chars match if (comment.charAt(comment.length - 1) === delimiter.charAt(delimiter.length - 1) && comment.indexOf(delimiter) !== -1) { break; } // only need to search for custom delimiter for the first few characters if (!matched) { matched = comment.length > 10; if (comment.indexOf(''; matched = true; } else if (comment.indexOf(''; matched = true; } else if (comment.indexOf(''; matched = true; } else if (comment.indexOf(''; matched = true; } else if (comment.indexOf('{{!--') === 0) { // {{!-- handlebars comment delimiter = '--}}'; matched = true; } else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment if (comment.length === 5 && comment.indexOf('{{!--') === -1) { delimiter = '}}'; matched = true; } } else if (comment.indexOf(''; matched = true; } else if (comment.indexOf('<%') === 0) { // {{! handlebars comment delimiter = '%>'; matched = true; } } input_char = this._input.next(); } var directives = directives_core.get_directives(comment); if (directives && directives.ignore === 'start') { comment += directives_core.readIgnored(this._input); } token = this._create_token(TOKEN.COMMENT, comment); token.directives = directives; } } return token; }; Tokenizer.prototype._read_open = function(c, open_token) { var resulting_string = null; var token = null; if (!open_token) { if (c === '<') { resulting_string = this._input.read(/<(?:[^\n\r\t >{][^\n\r\t >{/]*)?/g); token = this._create_token(TOKEN.TAG_OPEN, resulting_string); } else if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') { resulting_string = this._input.readUntil(/[\n\r\t }]/g); token = this._create_token(TOKEN.TAG_OPEN, resulting_string); } } return token; }; Tokenizer.prototype._read_close = function(c, open_token) { var resulting_string = null; var token = null; if (open_token) { if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) { resulting_string = this._input.next(); if (c === '/') { // for close tag "/>" resulting_string += this._input.next(); } token = this._create_token(TOKEN.TAG_CLOSE, resulting_string); } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') { this._input.next(); this._input.next(); token = this._create_token(TOKEN.TAG_CLOSE, '}}'); } } return token; }; Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) { var token = null; var resulting_string = ''; if (open_token && open_token.text[0] === '<') { if (c === '=') { token = this._create_token(TOKEN.EQUALS, this._input.next()); } else if (c === '"' || c === "'") { var content = this._input.next(); var input_string = ''; var string_pattern = new RegExp(c + '|{{', 'g'); while (this._input.hasNext()) { input_string = this._input.readUntilAfter(string_pattern); content += input_string; if (input_string[input_string.length - 1] === '"' || input_string[input_string.length - 1] === "'") { break; } else if (this._input.hasNext()) { content += this._input.readUntilAfter(/}}/g); } } token = this._create_token(TOKEN.VALUE, content); } else { if (c === '{' && this._input.peek(1) === '{') { resulting_string = this._input.readUntilAfter(/}}/g); } else { resulting_string = this._input.readUntil(/[\n\r\t =\/>]/g); } if (resulting_string) { if (previous_token.type === TOKEN.EQUALS) { token = this._create_token(TOKEN.VALUE, resulting_string); } else { token = this._create_token(TOKEN.ATTRIBUTE, resulting_string); } } } } return token; }; Tokenizer.prototype._is_content_unformatted = function(tag_name) { // void_elements have no content and so cannot have unformatted content // script and style tags should always be read as unformatted content // finally content_unformatted and unformatted element contents are unformatted return this._options.void_elements.indexOf(tag_name) === -1 && (tag_name === 'script' || tag_name === 'style' || this._options.content_unformatted.indexOf(tag_name) !== -1 || this._options.unformatted.indexOf(tag_name) !== -1); }; Tokenizer.prototype._read_raw_content = function(previous_token, open_token) { // jshint unused:false var resulting_string = ''; if (open_token && open_token.text[0] === '{') { resulting_string = this._input.readUntil(/}}/g); } else if (previous_token.type === TOKEN.TAG_CLOSE && (previous_token.opened.text[0] === '<')) { var tag_name = previous_token.opened.text.substr(1).toLowerCase(); if (this._is_content_unformatted(tag_name)) { resulting_string = this._input.readUntil(new RegExp('', 'ig')); } } if (resulting_string) { return this._create_token(TOKEN.TEXT, resulting_string); } return null; }; Tokenizer.prototype._read_content_word = function() { // if we get here and we see handlebars treat them as plain text var resulting_string = this._input.readUntil(this._word_pattern); if (resulting_string) { return this._create_token(TOKEN.TEXT, resulting_string); } }; module.exports.Tokenizer = Tokenizer; module.exports.TOKEN = TOKEN; /***/ }) /******/ ]); var style_html = legacy_beautify_html; /* Footer */ if (typeof define === "function" && define.amd) { // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- ) define(["require", "./beautify", "./beautify-css"], function(requireamd) { var js_beautify = requireamd("./beautify"); var css_beautify = requireamd("./beautify-css"); return { html_beautify: function(html_source, options) { return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify); } }; }); } else if (typeof exports !== "undefined") { // Add support for CommonJS. Just put this file somewhere on your require.paths // and you will be able to `var html_beautify = require("beautify").html_beautify`. var js_beautify = require('./beautify.js'); var css_beautify = require('./beautify-css.js'); exports.html_beautify = function(html_source, options) { return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify); }; } else if (typeof window !== "undefined") { // If we're running a web page and don't have either of the above, add our one global window.html_beautify = function(html_source, options) { return style_html(html_source, options, window.js_beautify, window.css_beautify); }; } else if (typeof global !== "undefined") { // If we don't even have window, try global. global.html_beautify = function(html_source, options) { return style_html(html_source, options, global.js_beautify, global.css_beautify); }; } }());