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, <einar@beautifier.io> https://beautifier.io/
Usage: style_html(html_source);
style_html(html_source, options);
The options are: indent_inner_html (default false) — indent <head> and <body> 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.
/* 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 = 18); /******/ }) /************************************************************************/ /******/ ([ /* 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.__wrap_point_index = 0; this.__wrap_point_character_count = 0; this.__wrap_point_indent_count = -1; this.__wrap_point_alignment_count = 0;
this.__items = [];
}
OutputLine.prototype.clone_empty = function() { var line = new OutputLine(this.__parent);
line.set_indent(this.__indent_count, this.__alignment_count); return line;
};
OutputLine.prototype.toString = function() { var result = ''; if (this.is_empty()) { if (this.__parent.indent_empty_lines) {
result = this.__parent.get_indent_string(this.__indent_count);
}
} else {
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
result += this.__items.join('');
} return result;
};
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);
}
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())) { returnfalse;
}
// if raw output is enabled, don't print additional newlines, // but still return True as though you had if (!this.raw) { this.__add_outputline();
} returntrue;
};
// handle some edge cases where the last tokens // has text that ends with newline(s) var last_item = this.current_line.pop(); if (last_item) { if (last_item[last_item.length - 1] === '\n') {
last_item = last_item.replace(/\n+$/g, '');
} this.current_line.push(last_item);
}
if (this._end_with_newline) { this.__add_outputline();
}
// Next line stores alignment values this.next_line.set_indent(indent, alignment);
// Never indent your first output indent at the start of the file if (this.__lines.length > 1) { this.current_line.set_indent(indent, alignment); returntrue;
}
this.current_line.set_indent(); returnfalse;
};
Output.prototype.add_raw_token = function(token) { for (var x = 0; x < token.newlines; x++) { this.__add_outputline();
} this.current_line.set_indent(-1); this.current_line.push(token.whitespace_before); this.current_line.push(token.text); this.space_before_token = false; this.non_breaking_space = false; this.previous_token_wrapped = false;
};
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.
*/
// 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;
}
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) { this.raw_options = _mergeOpts(options, merge_child_field);
// Support passing the source text back with no change this.disabled = this._get_boolean('disabled');
// 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 this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
// valid templating languages ['django', 'erb', 'handlebars', 'php'] // For now, 'auto' = all off for javascript, all on for html (and inline javascript). // other values ignored this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
}
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();
}
} elseif (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) { thrownew 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) { thrownew Error("Selection list cannot be empty.");
}
var result = this._get_array(name, default_value); if (!this._is_valid_selection(result, selection_list)) { thrownew Error( "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
}
// merges child options up with the parent options object // Example: obj = {a: 1, b: {a: 2}} // mergeOpts(obj, 'b') // // Returns: {a: 2} function _mergeOpts(allOptions, childFieldName) { var finalOpts = {};
allOptions = _normalizeOpts(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;
}
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 regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
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;
};
// This is a JavaScript only helper function (not in python) // Javascript doesn't have a match method // and not all implementation support "sticky" flag. // If they do not support sticky then both this.match() and this.test() method // must get the match and check the index of the match. // If sticky is supported and set, this method will use it. // Otherwise it will check that global is set, and fall back to the slower method.
InputScanner.prototype.__match = function(pattern, index) {
pattern.lastIndex = index; var pattern_match = pattern.exec(this.__input);
if (pattern_match && !(regexp_has_sticky && pattern.sticky)) { if (pattern_match.index !== index) {
pattern_match = null;
}
}
return pattern_match;
};
InputScanner.prototype.test = function(pattern, index) {
index = index || 0;
index += this.__position;
if (index >= 0 && index < this.__input_length) { return !!this.__match(pattern, index);
} else { returnfalse;
}
};
InputScanner.prototype.testChar = function(pattern, index) { // test one character regex match var val = this.peek(index);
pattern.lastIndex = 0; return val !== null && pattern.test(val);
};
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) { var val = ''; var match; if (starting_pattern) {
match = this.match(starting_pattern); if (match) {
val += match[0];
}
} if (until_pattern && (match || !starting_pattern)) {
val += this.readUntil(until_pattern, until_after);
} return val;
};
InputScanner.prototype.readUntil = function(pattern, until_after) { var val = ''; var match_index = this.__position;
pattern.lastIndex = this.__position; var pattern_match = pattern.exec(this.__input); if (pattern_match) {
match_index = pattern_match.index; if (until_after) {
match_index += pattern_match[0].length;
}
} else {
match_index = this.__input_length;
}
val = this.__input.substring(this.__position, match_index); this.__position = match_index; return val;
};
InputScanner.prototype.get_regexp = function(pattern, match_from) { var result = null; var flags = 'g'; if (match_from && regexp_has_sticky) {
flags = 'y';
} // strings are converted to regexp if (typeof pattern === "string" && pattern !== '') { // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
result = new RegExp(pattern, flags);
} elseif (pattern) {
result = new RegExp(pattern.source, flags);
} return result;
};
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 WhitespacePattern = __webpack_require__(11).WhitespacePattern;
var Tokenizer = function(input_string, options) { this._input = new InputScanner(input_string); this._options = options || {}; this.__tokens = null;
this._patterns = {}; this._patterns.whitespace = new WhitespacePattern(this._input);
};
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();
}
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.
*/
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;
};
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 Pattern = __webpack_require__(12).Pattern;
function WhitespacePattern(input_scanner, parent) {
Pattern.call(this, input_scanner, parent); if (parent) { this._line_regexp = this._input.get_regexp(parent._line_regexp);
} else { this.__set_whitespace_patterns('', '');
}
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.
*/
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.
*/
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.
*/
// This lets templates appear anywhere we would do a readUntil // The cost is higher but it is pay to play. function TemplatablePattern(input_scanner, parent) {
Pattern.call(this, input_scanner, parent); this.__template_pattern = null; this._disabled = Object.assign({}, template_names); this._excluded = Object.assign({}, template_names);
if (parent) { this.__template_pattern = this._input.get_regexp(parent.__template_pattern); this._excluded = Object.assign(this._excluded, parent._excluded); this._disabled = Object.assign(this._disabled, parent._disabled);
} var pattern = new Pattern(input_scanner); this.__patterns = {
handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
handlebars: pattern.starting_with(/{{/).until_after(/}}/),
php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/), // django coflicts with handlebars a bit.
django: pattern.starting_with(/{%/).until_after(/%}/),
django_value: pattern.starting_with(/{{/).until_after(/}}/),
django_comment: pattern.starting_with(/{#/).until_after(/#}/)
};
}
TemplatablePattern.prototype = new Pattern();
TemplatablePattern.prototype.disable = function(language) { var result = this._create();
result._disabled[language] = true;
result._update(); return result;
};
TemplatablePattern.prototype.read_options = function(options) { var result = this._create(); for (var language in template_names) {
result._disabled[language] = options.templating.indexOf(language) === -1;
}
result._update(); return result;
};
TemplatablePattern.prototype.exclude = function(language) { var result = this._create();
result._excluded[language] = true;
result._update(); return result;
};
TemplatablePattern.prototype.read = function() { var result = ''; if (this._match_pattern) {
result = this._input.read(this._starting_pattern);
} else {
result = this._input.read(this._starting_pattern, this.__template_pattern);
} var next = this._read_template(); while (next) { if (this._match_pattern) {
next += this._input.read(this._match_pattern);
} else {
next += this._input.readUntil(this.__template_pattern);
}
result += next;
next = this._read_template();
}
if (this._until_after) {
result += this._input.readUntilAfter(this._until_pattern);
} return result;
};
TemplatablePattern.prototype.__set_templated_pattern = function() { var items = [];
if (!this._disabled.php) {
items.push(this.__patterns.php._starting_pattern.source);
} if (!this._disabled.handlebars) {
items.push(this.__patterns.handlebars._starting_pattern.source);
} if (!this._disabled.erb) {
items.push(this.__patterns.erb._starting_pattern.source);
} if (!this._disabled.django) {
items.push(this.__patterns.django._starting_pattern.source);
items.push(this.__patterns.django_value._starting_pattern.source);
items.push(this.__patterns.django_comment._starting_pattern.source);
}
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__(19).Beautifier,
Options = __webpack_require__(20).Options;
function style_html(html_source, options, js_beautify, css_beautify) { var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify); return beautifier.beautify();
}
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__(20).Options; var Output = __webpack_require__(2).Output; var Tokenizer = __webpack_require__(21).Tokenizer; var TOKEN = __webpack_require__(21).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
// For script and style tags that have a type attribute, only enable custom beautifiers for matching values // For those without a type attribute use default; if (typeAttribute.search('text/css') > -1) {
result = 'css';
} elseif (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
result = 'javascript';
} elseif (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
result = 'html';
} elseif (typeAttribute.search(/test\/null/) > -1) { // Test only mime-type for testing the beautifier when null is passed as beautifing function
result = 'null';
}
return result;
};
function in_array(what, arr) { return arr.indexOf(what) !== -1;
}
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;
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;
} elseif (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); returnthis._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');
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true); 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] === '/', true); // 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);
}
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;
}
if (!last_tag_token.is_inline_element &&
!(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
printer.set_wrap_point();
}
return parser_token;
};
Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) { var wrapped = last_tag_token.has_wrapped_attrs; var parser_token = {
text: raw_token.text,
type: raw_token.type
};
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true); if (last_tag_token.is_unformatted) {
printer.add_raw_token(raw_token);
} elseif (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)) {
raw_token.newlines = 0;
printer.add_raw_token(raw_token);
} else {
printer.print_token(raw_token);
}
} else { if (raw_token.type === TOKEN.ATTRIBUTE) {
printer.set_space_before_token(true);
last_tag_token.attr_count += 1;
} elseif (raw_token.type === TOKEN.EQUALS) { //no space before =
printer.set_space_before_token(false);
} elseif (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) { //no space before value
printer.set_space_before_token(false);
}
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]*$/, '');
// Handle the case where content is wrapped in a comment or cdata. if (last_tag_token.custom_beautifier_name !== 'html' &&
text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) { var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
// if we start to wrap but don't finish, print raw if (!matched) {
printer.add_raw_token(raw_token); return;
}
pre = indentation + matched[1] + '\n';
text = matched[4]; if (matched[5]) {
post = indentation + matched[5];
}
// 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 (matched[2] || matched[3].indexOf('\n') !== -1) { // if the first line of the non-comment text has spaces // use that as the basis for indenting in null case.
matched = matched[3].match(/[ \t]+$/); if (matched) {
raw_token.whitespace_before = matched[0];
}
}
}
if (text) { 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 = raw_token.whitespace_before; if (white) {
text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
}
text = indentation + text.replace(/\n/g, '\n' + indentation);
}
}
if (pre) { if (!text) {
text = pre + post;
} else {
text = pre + text + '\n' + post;
}
}
if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
!last_tag_token.is_empty_element &&
raw_token.type === TOKEN.TAG_OPEN && raw_token.text.indexOf('</') === 0) { // End element tags for unformatted or content_unformatted elements // are printed raw to keep any newlines inside them exactly the same.
printer.add_raw_token(raw_token);
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
} else {
printer.traverse_whitespace(raw_token); this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token); if (!parser_token.is_inline_element) {
printer.set_wrap_point();
}
printer.print_token(raw_token);
}
//indent attributes an auto, forced, aligned or forced-align line-wrap if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
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;
}
// 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);
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 if (this._do_optional_end_element(parser_token)) { if (!parser_token.is_inline_element) {
printer.print_newline(false);
}
}
this._tag_stack.record_tag(parser_token); //push it on the tag stack
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);
} this._calcluate_parent_multiline(printer, parser_token);
}
} elseif (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending var do_end_expand = false;
// deciding whether a block is multiline should not be this hard
do_end_expand = parser_token.start_tag_token && parser_token.start_tag_token.multiline_content;
do_end_expand = do_end_expand || (!parser_token.is_inline_element &&
!(last_tag_token.is_inline_element || last_tag_token.is_unformatted) &&
!(last_token.type === TOKEN.TAG_CLOSE && parser_token.start_tag_token === last_tag_token) &&
last_token.type !== 'TK_CONTENT'
);
if (parser_token.is_content_unformatted || parser_token.is_unformatted) {
do_end_expand = false;
}
if (do_end_expand) {
printer.print_newline(false);
}
} else { // it's a start-tag
parser_token.indent_content = !parser_token.custom_beautifier_name;
//To be used for <p> 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']; var p_parent_excludes = ['a', 'audio', 'del', 'ins', 'map', 'noscript', 'video'];
Beautifier.prototype._do_optional_end_element = function(parser_token) { var result = null; // 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;
}
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.
result = result || 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.
} elseif (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.
result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
} elseif (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.
result = result || this._tag_stack.try_pop('dt', ['dl']);
result = result || this._tag_stack.try_pop('dd', ['dl']);
} elseif (parser_token.parent.tag_name === 'p' && p_closers.indexOf(parser_token.tag_name) !== -1) { // IMPORTANT: this else-if works because p_closers has no overlap with any other element we look for in this method // check for 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. // To do this right, this needs to be coded as an inclusion of the inverse of the exclusion above. // But to start with (if we ignore "autonomous custom elements") the exclusion would be fine. var p_parent = parser_token.parent.parent; if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
result = result || this._tag_stack.try_pop('p');
}
} elseif (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.
result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
} elseif (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.
result = result || this._tag_stack.try_pop('optgroup', ['select']); //result = result || this._tag_stack.try_pop('option', ['select']);
} elseif (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.
result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
} elseif (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.
result = result || this._tag_stack.try_pop('caption', ['table']);
} elseif (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.
result = result || this._tag_stack.try_pop('caption', ['table']);
result = result || 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.
} elseif (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.
result = result || this._tag_stack.try_pop('caption', ['table']);
result = result || this._tag_stack.try_pop('colgroup', ['table']);
result = result || this._tag_stack.try_pop('thead', ['table']);
result = result || 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.
} elseif (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.
result = result || this._tag_stack.try_pop('caption', ['table']);
result = result || this._tag_stack.try_pop('colgroup', ['table']);
result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
} elseif (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.
result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', '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();
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.
*/
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__(13).Directives; var TemplatablePattern = __webpack_require__(14).TemplatablePattern; var Pattern = __webpack_require__(12).Pattern;
// Words end at whitespace or when a tag starts // if we are indenting handlebars, they are considered tags var templatable_reader = new TemplatablePattern(this._input).read_options(this._options); var pattern_reader = new Pattern(this._input);
Tokenizer.prototype._read_comment_or_cdata = function(c) { // jshint unused:false var token = null; var resulting_string = null; var directives = null;
if (c === '<') { var peek1 = this._input.peek(1); // We treat all comments as literals, even more than preformatted tags // we only look for the appropriate closing marker if (peek1 === '!') {
resulting_string = this.__patterns.comment.read();
// only process directive on html comments if (resulting_string) {
directives = directives_core.get_directives(resulting_string); if (directives && directives.ignore === 'start') {
resulting_string += directives_core.readIgnored(this._input);
}
} else {
resulting_string = this.__patterns.cdata.read();
}
}
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 returnthis._options.void_elements.indexOf(tag_name) === -1 &&
(this._options.content_unformatted.indexOf(tag_name) !== -1 || this._options.unformatted.indexOf(tag_name) !== -1);
};
Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false var resulting_string = ''; if (open_token && open_token.text[0] === '{') {
resulting_string = this.__patterns.handlebars_raw_close.read();
} elseif (previous_token.type === TOKEN.TAG_CLOSE &&
previous_token.opened.text[0] === '<' && previous_token.text[0] !== '/') { // ^^ empty tag has no content var tag_name = previous_token.opened.text.substr(1).toLowerCase(); if (tag_name === 'script' || tag_name === 'style') { // Script and style tags are allowed to have comments wrapping their content // or just have regular content. var token = this._read_comment_or_cdata(c); if (token) {
token.type = TOKEN.TEXT; return token;
}
resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
} elseif (this._is_content_unformatted(tag_name)) {
/***/ }) /******/ ]); 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);
}
};
});
} elseif (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.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);
};
} elseif (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);
};
} elseif (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);
};
}
}());
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.61 Sekunden
(vorverarbeitet am 2026-04-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.