PageSourceSearch

https://www.city.wajima.ishikawa.jp/_common/assets/base/js-beautify/beautify-html.js

js city.wajima.ishikawa.jp collected 2026-09-24 09:52:01 UTC 114,831 bytes, 3,242 lines download raw bytes

1/* AUTO-GENERATED. DO NOT MODIFY. */
2/*
3
4  The MIT License (MIT)
5
6  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
7
8  Permission is hereby granted, free of charge, to any person
9  obtaining a copy of this software and associated documentation files
10  (the "Software"), to deal in the Software without restriction,
11  including without limitation the rights to use, copy, modify, merge,
12  publish, distribute, sublicense, and/or sell copies of the Software,
13  and to permit persons to whom the Software is furnished to do so,
14  subject to the following conditions:
15
16  The above copyright notice and this permission notice shall be
17  included in all copies or substantial portions of the Software.
18
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  SOFTWARE.
27
28
29 Style HTML
30---------------
31
32  Written by Nochum Sossonko, ([email protected])
33
34  Based on code initially developed by: Einar Lielmanis, <[email protected]>
35    https://beautifier.io/
36
37  Usage:
38    style_html(html_source);
39
40    style_html(html_source, options);
41
42  The options are:
43    indent_inner_html (default false)  — indent <head> and <body> sections,
44    indent_size (default 4)          — indentation size,
45    indent_char (default space)      — character to indent with,
46    wrap_line_length (default 250)            -  maximum amount of characters per line (0 = disable)
47    brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
48            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.
49    inline (defaults to inline tags) - list of tags to be considered inline tags
50    unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
51    content_unformatted (defaults to ["pre", "textarea"] tags) - list of tags, whose content shouldn't be reformatted
52    indent_scripts (default normal)  - "keep"|"separate"|"normal"
53    preserve_newlines (default true) - whether existing line breaks before elements should be preserved
54                                        Only works before elements, not inside tags or for text.
55    max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk
56    indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}}
57    end_with_newline (false)          - end with a newline
58    extra_liners (default [head,body,/html]) -List of tags that should have an extra newline before them.
59
60    e.g.
61
62    style_html(html_source, {
63      'indent_inner_html': false,
64      'indent_size': 2,
65      'indent_char': ' ',
66      'wrap_line_length': 78,
67      'brace_style': 'expand',
68      'preserve_newlines': true,
69      'max_preserve_newlines': 5,
70      'indent_handlebars': false,
71      'extra_liners': ['/html']
72    });
73*/
74
75(function() {
76
77/* GENERATED_BUILD_OUTPUT */
78var legacy_beautify_html;
79/******/ (function() { // webpackBootstrap
80/******/ 	"use strict";
81/******/ 	var __webpack_modules__ = ([
82/* 0 */,
83/* 1 */,
84/* 2 */
85/***/ (function(module) {
86
87/*jshint node:true */
88/*
89  The MIT License (MIT)
90
91  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
92
93  Permission is hereby granted, free of charge, to any person
94  obtaining a copy of this software and associated documentation files
95  (the "Software"), to deal in the Software without restriction,
96  including without limitation the rights to use, copy, modify, merge,
97  publish, distribute, sublicense, and/or sell copies of the Software,
98  and to permit persons to whom the Software is furnished to do so,
99  subject to the following conditions:
100
101  The above copyright notice and this permission notice shall be
102  included in all copies or substantial portions of the Software.
103
104  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
105  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
106  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
107  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
108  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
109  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
110  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
111  SOFTWARE.
112*/
113
114
115
116function OutputLine(parent) {
117  this.__parent = parent;
118  this.__character_count = 0;
119  // use indent_count as a marker for this.__lines that have preserved indentation
120  this.__indent_count = -1;
121  this.__alignment_count = 0;
122  this.__wrap_point_index = 0;
123  this.__wrap_point_character_count = 0;
124  this.__wrap_point_indent_count = -1;
125  this.__wrap_point_alignment_count = 0;
126
127  this.__items = [];
128}
129
130OutputLine.prototype.clone_empty = function() {
131  var line = new OutputLine(this.__parent);
132  line.set_indent(this.__indent_count, this.__alignment_count);
133  return line;
134};
135
136OutputLine.prototype.item = function(index) {
137  if (index < 0) {
138    return this.__items[this.__items.length + index];
139  } else {
140    return this.__items[index];
141  }
142};
143
144OutputLine.prototype.has_match = function(pattern) {
145  for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
146    if (this.__items[lastCheckedOutput].match(pattern)) {
147      return true;
148    }
149  }
150  return false;
151};
152
153OutputLine.prototype.set_indent = function(indent, alignment) {
154  if (this.is_empty()) {
155    this.__indent_count = indent || 0;
156    this.__alignment_count = alignment || 0;
157    this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
158  }
159};
160
161OutputLine.prototype._set_wrap_point = function() {
162  if (this.__parent.wrap_line_length) {
163    this.__wrap_point_index = this.__items.length;
164    this.__wrap_point_character_count = this.__character_count;
165    this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
166    this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
167  }
168};
169
170OutputLine.prototype._should_wrap = function() {
171  return this.__wrap_point_index &&
172    this.__character_count > this.__parent.wrap_line_length &&
173    this.__wrap_point_character_count > this.__parent.next_line.__character_count;
174};
175
176OutputLine.prototype._allow_wrap = function() {
177  if (this._should_wrap()) {
178    this.__parent.add_new_line();
179    var next = this.__parent.current_line;
180    next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
181    next.__items = this.__items.slice(this.__wrap_point_index);
182    this.__items = this.__items.slice(0, this.__wrap_point_index);
183
184    next.__character_count += this.__character_count - this.__wrap_point_character_count;
185    this.__character_count = this.__wrap_point_character_count;
186
187    if (next.__items[0] === " ") {
188      next.__items.splice(0, 1);
189      next.__character_count -= 1;
190    }
191    return true;
192  }
193  return false;
194};
195
196OutputLine.prototype.is_empty = function() {
197  return this.__items.length === 0;
198};
199
200OutputLine.prototype.last = function() {
201  if (!this.is_empty()) {
202    return this.__items[this.__items.length - 1];
203  } else {
204    return null;
205  }
206};
207
208OutputLine.prototype.push = function(item) {
209  this.__items.push(item);
210  var last_newline_index = item.lastIndexOf('\n');
211  if (last_newline_index !== -1) {
212    this.__character_count = item.length - last_newline_index;
213  } else {
214    this.__character_count += item.length;
215  }
216};
217
218OutputLine.prototype.pop = function() {
219  var item = null;
220  if (!this.is_empty()) {
221    item = this.__items.pop();
222    this.__character_count -= item.length;
223  }
224  return item;
225};
226
227
228OutputLine.prototype._remove_indent = function() {
229  if (this.__indent_count > 0) {
230    this.__indent_count -= 1;
231    this.__character_count -= this.__parent.indent_size;
232  }
233};
234
235OutputLine.prototype._remove_wrap_indent = function() {
236  if (this.__wrap_point_indent_count > 0) {
237    this.__wrap_point_indent_count -= 1;
238  }
239};
240OutputLine.prototype.trim = function() {
241  while (this.last() === ' ') {
242    this.__items.pop();
243    this.__character_count -= 1;
244  }
245};
246
247OutputLine.prototype.toString = function() {
248  var result = '';
249  if (this.is_empty()) {
250    if (this.__parent.indent_empty_lines) {
251      result = this.__parent.get_indent_string(this.__indent_count);
252    }
253  } else {
254    result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
255    result += this.__items.join('');
256  }
257  return result;
258};
259
260function IndentStringCache(options, baseIndentString) {
261  this.__cache = [''];
262  this.__indent_size = options.indent_size;
263  this.__indent_string = options.indent_char;
264  if (!options.indent_with_tabs) {
265    this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
266  }
267
268  // Set to null to continue support for auto detection of base indent
269  baseIndentString = baseIndentString || '';
270  if (options.indent_level > 0) {
271    baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
272  }
273
274  this.__base_string = baseIndentString;
275  this.__base_string_length = baseIndentString.length;
276}
277
278IndentStringCache.prototype.get_indent_size = function(indent, column) {
279  var result = this.__base_string_length;
280  column = column || 0;
281  if (indent < 0) {
282    result = 0;
283  }
284  result += indent * this.__indent_size;
285  result += column;
286  return result;
287};
288
289IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
290  var result = this.__base_string;
291  column = column || 0;
292  if (indent_level < 0) {
293    indent_level = 0;
294    result = '';
295  }
296  column += indent_level * this.__indent_size;
297  this.__ensure_cache(column);
298  result += this.__cache[column];
299  return result;
300};
301
302IndentStringCache.prototype.__ensure_cache = function(column) {
303  while (column >= this.__cache.length) {
304    this.__add_column();
305  }
306};
307
308IndentStringCache.prototype.__add_column = function() {
309  var column = this.__cache.length;
310  var indent = 0;
311  var result = '';
312  if (this.__indent_size && column >= this.__indent_size) {
313    indent = Math.floor(column / this.__indent_size);
314    column -= indent * this.__indent_size;
315    result = new Array(indent + 1).join(this.__indent_string);
316  }
317  if (column) {
318    result += new Array(column + 1).join(' ');
319  }
320
321  this.__cache.push(result);
322};
323
324function Output(options, baseIndentString) {
325  this.__indent_cache = new IndentStringCache(options, baseIndentString);
326  this.raw = false;
327  this._end_with_newline = options.end_with_newline;
328  this.indent_size = options.indent_size;
329  this.wrap_line_length = options.wrap_line_length;
330  this.indent_empty_lines = options.indent_empty_lines;
331  this.__lines = [];
332  this.previous_line = null;
333  this.current_line = null;
334  this.next_line = new OutputLine(this);
335  this.space_before_token = false;
336  this.non_breaking_space = false;
337  this.previous_token_wrapped = false;
338  // initialize
339  this.__add_outputline();
340}
341
342Output.prototype.__add_outputline = function() {
343  this.previous_line = this.current_line;
344  this.current_line = this.next_line.clone_empty();
345  this.__lines.push(this.current_line);
346};
347
348Output.prototype.get_line_number = function() {
349  return this.__lines.length;
350};
351
352Output.prototype.get_indent_string = function(indent, column) {
353  return this.__indent_cache.get_indent_string(indent, column);
354};
355
356Output.prototype.get_indent_size = function(indent, column) {
357  return this.__indent_cache.get_indent_size(indent, column);
358};
359
360Output.prototype.is_empty = function() {
361  return !this.previous_line && this.current_line.is_empty();
362};
363
364Output.prototype.add_new_line = function(force_newline) {
365  // never newline at the start of file
366  // otherwise, newline only if we didn't just add one or we're forced
367  if (this.is_empty() ||
368    (!force_newline && this.just_added_newline())) {
369    return false;
370  }
371
372  // if raw output is enabled, don't print additional newlines,
373  // but still return True as though you had
374  if (!this.raw) {
375    this.__add_outputline();
376  }
377  return true;
378};
379
380Output.prototype.get_code = function(eol) {
381  this.trim(true);
382
383  // handle some edge cases where the last tokens
384  // has text that ends with newline(s)
385  var last_item = this.current_line.pop();
386  if (last_item) {
387    if (last_item[last_item.length - 1] === '\n') {
388      last_item = last_item.replace(/\n+$/g, '');
389    }
390    this.current_line.push(last_item);
391  }
392
393  if (this._end_with_newline) {
394    this.__add_outputline();
395  }
396
397  var sweet_code = this.__lines.join('\n');
398
399  if (eol !== '\n') {
400    sweet_code = sweet_code.replace(/[\n]/g, eol);
401  }
402  return sweet_code;
403};
404
405Output.prototype.set_wrap_point = function() {
406  this.current_line._set_wrap_point();
407};
408
409Output.prototype.set_indent = function(indent, alignment) {
410  indent = indent || 0;
411  alignment = alignment || 0;
412
413  // Next line stores alignment values
414  this.next_line.set_indent(indent, alignment);
415
416  // Never indent your first output indent at the start of the file
417  if (this.__lines.length > 1) {
418    this.current_line.set_indent(indent, alignment);
419    return true;
420  }
421
422  this.current_line.set_indent();
423  return false;
424};
425
426Output.prototype.add_raw_token = function(token) {
427  for (var x = 0; x < token.newlines; x++) {
428    this.__add_outputline();
429  }
430  this.current_line.set_indent(-1);
431  this.current_line.push(token.whitespace_before);
432  this.current_line.push(token.text);
433  this.space_before_token = false;
434  this.non_breaking_space = false;
435  this.previous_token_wrapped = false;
436};
437
438Output.prototype.add_token = function(printable_token) {
439  this.__add_space_before_token();
440  this.current_line.push(printable_token);
441  this.space_before_token = false;
442  this.non_breaking_space = false;
443  this.previous_token_wrapped = this.current_line._allow_wrap();
444};
445
446Output.prototype.__add_space_before_token = function() {
447  if (this.space_before_token && !this.just_added_newline()) {
448    if (!this.non_breaking_space) {
449      this.set_wrap_point();
450    }
451    this.current_line.push(' ');
452  }
453};
454
455Output.prototype.remove_indent = function(index) {
456  var output_length = this.__lines.length;
457  while (index < output_length) {
458    this.__lines[index]._remove_indent();
459    index++;
460  }
461  this.current_line._remove_wrap_indent();
462};
463
464Output.prototype.trim = function(eat_newlines) {
465  eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
466
467  this.current_line.trim();
468
469  while (eat_newlines && this.__lines.length > 1 &&
470    this.current_line.is_empty()) {
471    this.__lines.pop();
472    this.current_line = this.__lines[this.__lines.length - 1];
473    this.current_line.trim();
474  }
475
476  this.previous_line = this.__lines.length > 1 ?
477    this.__lines[this.__lines.length - 2] : null;
478};
479
480Output.prototype.just_added_newline = function() {
481  return this.current_line.is_empty();
482};
483
484Output.prototype.just_added_blankline = function() {
485  return this.is_empty() ||
486    (this.current_line.is_empty() && this.previous_line.is_empty());
487};
488
489Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
490  var index = this.__lines.length - 2;
491  while (index >= 0) {
492    var potentialEmptyLine = this.__lines[index];
493    if (potentialEmptyLine.is_empty()) {
494      break;
495    } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
496      potentialEmptyLine.item(-1) !== ends_with) {
497      this.__lines.splice(index + 1, 0, new OutputLine(this));
498      this.previous_line = this.__lines[this.__lines.length - 2];
499      break;
500    }
501    index--;
502  }
503};
504
505module.exports.Output = Output;
506
507
508/***/ }),
509/* 3 */
510/***/ (function(module) {
511
512/*jshint node:true */
513/*
514
515  The MIT License (MIT)
516
517  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
518
519  Permission is hereby granted, free of charge, to any person
520  obtaining a copy of this software and associated documentation files
521  (the "Software"), to deal in the Software without restriction,
522  including without limitation the rights to use, copy, modify, merge,
523  publish, distribute, sublicense, and/or sell copies of the Software,
524  and to permit persons to whom the Software is furnished to do so,
525  subject to the following conditions:
526
527  The above copyright notice and this permission notice shall be
528  included in all copies or substantial portions of the Software.
529
530  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
531  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
532  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
533  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
534  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
535  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
536  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
537  SOFTWARE.
538*/
539
540
541
542function Token(type, text, newlines, whitespace_before) {
543  this.type = type;
544  this.text = text;
545
546  // comments_before are
547  // comments that have a new line before them
548  // and may or may not have a newline after
549  // this is a set of comments before
550  this.comments_before = null; /* inline comment*/
551
552
553  // this.comments_after =  new TokenStream(); // no new line before and newline after
554  this.newlines = newlines || 0;
555  this.whitespace_before = whitespace_before || '';
556  this.parent = null;
557  this.next = null;
558  this.previous = null;
559  this.opened = null;
560  this.closed = null;
561  this.directives = null;
562}
563
564
565module.exports.Token = Token;
566
567
568/***/ }),
569/* 4 */,
570/* 5 */,
571/* 6 */
572/***/ (function(module) {
573
574/*jshint node:true */
575/*
576
577  The MIT License (MIT)
578
579  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
580
581  Permission is hereby granted, free of charge, to any person
582  obtaining a copy of this software and associated documentation files
583  (the "Software"), to deal in the Software without restriction,
584  including without limitation the rights to use, copy, modify, merge,
585  publish, distribute, sublicense, and/or sell copies of the Software,
586  and to permit persons to whom the Software is furnished to do so,
587  subject to the following conditions:
588
589  The above copyright notice and this permission notice shall be
590  included in all copies or substantial portions of the Software.
591
592  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
593  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
594  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
595  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
596  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
597  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
598  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
599  SOFTWARE.
600*/
601
602
603
604function Options(options, merge_child_field) {
605  this.raw_options = _mergeOpts(options, merge_child_field);
606
607  // Support passing the source text back with no change
608  this.disabled = this._get_boolean('disabled');
609
610  this.eol = this._get_characters('eol', 'auto');
611  this.end_with_newline = this._get_boolean('end_with_newline');
612  this.indent_size = this._get_number('indent_size', 4);
613  this.indent_char = this._get_characters('indent_char', ' ');
614  this.indent_level = this._get_number('indent_level');
615
616  this.preserve_newlines = this._get_boolean('preserve_newlines', true);
617  this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
618  if (!this.preserve_newlines) {
619    this.max_preserve_newlines = 0;
620  }
621
622  this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
623  if (this.indent_with_tabs) {
624    this.indent_char = '\t';
625
626    // indent_size behavior changed after 1.8.6
627    // It used to be that indent_size would be
628    // set to 1 for indent_with_tabs. That is no longer needed and
629    // actually doesn't make sense - why not use spaces? Further,
630    // that might produce unexpected behavior - tabs being used
631    // for single-column alignment. So, when indent_with_tabs is true
632    // and indent_size is 1, reset indent_size to 4.
633    if (this.indent_size === 1) {
634      this.indent_size = 4;
635    }
636  }
637
638  // Backwards compat with 1.3.x
639  this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
640
641  this.indent_empty_lines = this._get_boolean('indent_empty_lines');
642
643  // valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular']
644  // For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css).
645  // other values ignored
646  this.templating = this._get_selection_list('templating', ['auto', 'none', 'angular', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']);
647}
648
649Options.prototype._get_array = function(name, default_value) {
650  var option_value = this.raw_options[name];
651  var result = default_value || [];
652  if (typeof option_value === 'object') {
653    if (option_value !== null && typeof option_value.concat === 'function') {
654      result = option_value.concat();
655    }
656  } else if (typeof option_value === 'string') {
657    result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
658  }
659  return result;
660};
661
662Options.prototype._get_boolean = function(name, default_value) {
663  var option_value = this.raw_options[name];
664  var result = option_value === undefined ? !!default_value : !!option_value;
665  return result;
666};
667
668Options.prototype._get_characters = function(name, default_value) {
669  var option_value = this.raw_options[name];
670  var result = default_value || '';
671  if (typeof option_value === 'string') {
672    result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
673  }
674  return result;
675};
676
677Options.prototype._get_number = function(name, default_value) {
678  var option_value = this.raw_options[name];
679  default_value = parseInt(default_value, 10);
680  if (isNaN(default_value)) {
681    default_value = 0;
682  }
683  var result = parseInt(option_value, 10);
684  if (isNaN(result)) {
685    result = default_value;
686  }
687  return result;
688};
689
690Options.prototype._get_selection = function(name, selection_list, default_value) {
691  var result = this._get_selection_list(name, selection_list, default_value);
692  if (result.length !== 1) {
693    throw new Error(
694      "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
695      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
696  }
697
698  return result[0];
699};
700
701
702Options.prototype._get_selection_list = function(name, selection_list, default_value) {
703  if (!selection_list || selection_list.length === 0) {
704    throw new Error("Selection list cannot be empty.");
705  }
706
707  default_value = default_value || [selection_list[0]];
708  if (!this._is_valid_selection(default_value, selection_list)) {
709    throw new Error("Invalid Default Value!");
710  }
711
712  var result = this._get_array(name, default_value);
713  if (!this._is_valid_selection(result, selection_list)) {
714    throw new Error(
715      "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
716      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
717  }
718
719  return result;
720};
721
722Options.prototype._is_valid_selection = function(result, selection_list) {
723  return result.length && selection_list.length &&
724    !result.some(function(item) { return selection_list.indexOf(item) === -1; });
725};
726
727
728// merges child options up with the parent options object
729// Example: obj = {a: 1, b: {a: 2}}
730//          mergeOpts(obj, 'b')
731//
732//          Returns: {a: 2}
733function _mergeOpts(allOptions, childFieldName) {
734  var finalOpts = {};
735  allOptions = _normalizeOpts(allOptions);
736  var name;
737
738  for (name in allOptions) {
739    if (name !== childFieldName) {
740      finalOpts[name] = allOptions[name];
741    }
742  }
743
744  //merge in the per type settings for the childFieldName
745  if (childFieldName && allOptions[childFieldName]) {
746    for (name in allOptions[childFieldName]) {
747      finalOpts[name] = allOptions[childFieldName][name];
748    }
749  }
750  return finalOpts;
751}
752
753function _normalizeOpts(options) {
754  var convertedOpts = {};
755  var key;
756
757  for (key in options) {
758    var newKey = key.replace(/-/g, "_");
759    convertedOpts[newKey] = options[key];
760  }
761  return convertedOpts;
762}
763
764module.exports.Options = Options;
765module.exports.normalizeOpts = _normalizeOpts;
766module.exports.mergeOpts = _mergeOpts;
767
768
769/***/ }),
770/* 7 */,
771/* 8 */
772/***/ (function(module) {
773
774/*jshint node:true */
775/*
776
777  The MIT License (MIT)
778
779  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
780
781  Permission is hereby granted, free of charge, to any person
782  obtaining a copy of this software and associated documentation files
783  (the "Software"), to deal in the Software without restriction,
784  including without limitation the rights to use, copy, modify, merge,
785  publish, distribute, sublicense, and/or sell copies of the Software,
786  and to permit persons to whom the Software is furnished to do so,
787  subject to the following conditions:
788
789  The above copyright notice and this permission notice shall be
790  included in all copies or substantial portions of the Software.
791
792  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
793  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
794  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
795  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
796  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
797  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
798  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
799  SOFTWARE.
800*/
801
802
803
804var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
805
806function InputScanner(input_string) {
807  this.__input = input_string || '';
808  this.__input_length = this.__input.length;
809  this.__position = 0;
810}
811
812InputScanner.prototype.restart = function() {
813  this.__position = 0;
814};
815
816InputScanner.prototype.back = function() {
817  if (this.__position > 0) {
818    this.__position -= 1;
819  }
820};
821
822InputScanner.prototype.hasNext = function() {
823  return this.__position < this.__input_length;
824};
825
826InputScanner.prototype.next = function() {
827  var val = null;
828  if (this.hasNext()) {
829    val = this.__input.charAt(this.__position);
830    this.__position += 1;
831  }
832  return val;
833};
834
835InputScanner.prototype.peek = function(index) {
836  var val = null;
837  index = index || 0;
838  index += this.__position;
839  if (index >= 0 && index < this.__input_length) {
840    val = this.__input.charAt(index);
841  }
842  return val;
843};
844
845// This is a JavaScript only helper function (not in python)
846// Javascript doesn't have a match method
847// and not all implementation support "sticky" flag.
848// If they do not support sticky then both this.match() and this.test() method
849// must get the match and check the index of the match.
850// If sticky is supported and set, this method will use it.
851// Otherwise it will check that global is set, and fall back to the slower method.
852InputScanner.prototype.__match = function(pattern, index) {
853  pattern.lastIndex = index;
854  var pattern_match = pattern.exec(this.__input);
855
856  if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
857    if (pattern_match.index !== index) {
858      pattern_match = null;
859    }
860  }
861
862  return pattern_match;
863};
864
865InputScanner.prototype.test = function(pattern, index) {
866  index = index || 0;
867  index += this.__position;
868
869  if (index >= 0 && index < this.__input_length) {
870    return !!this.__match(pattern, index);
871  } else {
872    return false;
873  }
874};
875
876InputScanner.prototype.testChar = function(pattern, index) {
877  // test one character regex match
878  var val = this.peek(index);
879  pattern.lastIndex = 0;
880  return val !== null && pattern.test(val);
881};
882
883InputScanner.prototype.match = function(pattern) {
884  var pattern_match = this.__match(pattern, this.__position);
885  if (pattern_match) {
886    this.__position += pattern_match[0].length;
887  } else {
888    pattern_match = null;
889  }
890  return pattern_match;
891};
892
893InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
894  var val = '';
895  var match;
896  if (starting_pattern) {
897    match = this.match(starting_pattern);
898    if (match) {
899      val += match[0];
900    }
901  }
902  if (until_pattern && (match || !starting_pattern)) {
903    val += this.readUntil(until_pattern, until_after);
904  }
905  return val;
906};
907
908InputScanner.prototype.readUntil = function(pattern, until_after) {
909  var val = '';
910  var match_index = this.__position;
911  pattern.lastIndex = this.__position;
912  var pattern_match = pattern.exec(this.__input);
913  if (pattern_match) {
914    match_index = pattern_match.index;
915    if (until_after) {
916      match_index += pattern_match[0].length;
917    }
918  } else {
919    match_index = this.__input_length;
920  }
921
922  val = this.__input.substring(this.__position, match_index);
923  this.__position = match_index;
924  return val;
925};
926
927InputScanner.prototype.readUntilAfter = function(pattern) {
928  return this.readUntil(pattern, true);
929};
930
931InputScanner.prototype.get_regexp = function(pattern, match_from) {
932  var result = null;
933  var flags = 'g';
934  if (match_from && regexp_has_sticky) {
935    flags = 'y';
936  }
937  // strings are converted to regexp
938  if (typeof pattern === "string" && pattern !== '') {
939    // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
940    result = new RegExp(pattern, flags);
941  } else if (pattern) {
942    result = new RegExp(pattern.source, flags);
943  }
944  return result;
945};
946
947InputScanner.prototype.get_literal_regexp = function(literal_string) {
948  return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
949};
950
951/* css beautifier legacy helpers */
952InputScanner.prototype.peekUntilAfter = function(pattern) {
953  var start = this.__position;
954  var val = this.readUntilAfter(pattern);
955  this.__position = start;
956  return val;
957};
958
959InputScanner.prototype.lookBack = function(testVal) {
960  var start = this.__position - 1;
961  return start >= testVal.length && this.__input.substring(start - testVal.length, start)
962    .toLowerCase() === testVal;
963};
964
965module.exports.InputScanner = InputScanner;
966
967
968/***/ }),
969/* 9 */
970/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
971
972/*jshint node:true */
973/*
974
975  The MIT License (MIT)
976
977  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
978
979  Permission is hereby granted, free of charge, to any person
980  obtaining a copy of this software and associated documentation files
981  (the "Software"), to deal in the Software without restriction,
982  including without limitation the rights to use, copy, modify, merge,
983  publish, distribute, sublicense, and/or sell copies of the Software,
984  and to permit persons to whom the Software is furnished to do so,
985  subject to the following conditions:
986
987  The above copyright notice and this permission notice shall be
988  included in all copies or substantial portions of the Software.
989
990  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
991  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
992  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
993  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
994  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
995  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
996  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
997  SOFTWARE.
998*/
999
1000
1001
1002var InputScanner = (__webpack_require__(8).InputScanner);
1003var Token = (__webpack_require__(3).Token);
1004var TokenStream = (__webpack_require__(10).TokenStream);
1005var WhitespacePattern = (__webpack_require__(11).WhitespacePattern);
1006
1007var TOKEN = {
1008  START: 'TK_START',
1009  RAW: 'TK_RAW',
1010  EOF: 'TK_EOF'
1011};
1012
1013var Tokenizer = function(input_string, options) {
1014  this._input = new InputScanner(input_string);
1015  this._options = options || {};
1016  this.__tokens = null;
1017
1018  this._patterns = {};
1019  this._patterns.whitespace = new WhitespacePattern(this._input);
1020};
1021
1022Tokenizer.prototype.tokenize = function() {
1023  this._input.restart();
1024  this.__tokens = new TokenStream();
1025
1026  this._reset();
1027
1028  var current;
1029  var previous = new Token(TOKEN.START, '');
1030  var open_token = null;
1031  var open_stack = [];
1032  var comments = new TokenStream();
1033
1034  while (previous.type !== TOKEN.EOF) {
1035    current = this._get_next_token(previous, open_token);
1036    while (this._is_comment(current)) {
1037      comments.add(current);
1038      current = this._get_next_token(previous, open_token);
1039    }
1040
1041    if (!comments.isEmpty()) {
1042      current.comments_before = comments;
1043      comments = new TokenStream();
1044    }
1045
1046    current.parent = open_token;
1047
1048    if (this._is_opening(current)) {
1049      open_stack.push(open_token);
1050      open_token = current;
1051    } else if (open_token && this._is_closing(current, open_token)) {
1052      current.opened = open_token;
1053      open_token.closed = current;
1054      open_token = open_stack.pop();
1055      current.parent = open_token;
1056    }
1057
1058    current.previous = previous;
1059    previous.next = current;
1060
1061    this.__tokens.add(current);
1062    previous = current;
1063  }
1064
1065  return this.__tokens;
1066};
1067
1068
1069Tokenizer.prototype._is_first_token = function() {
1070  return this.__tokens.isEmpty();
1071};
1072
1073Tokenizer.prototype._reset = function() {};
1074
1075Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
1076  this._readWhitespace();
1077  var resulting_string = this._input.read(/.+/g);
1078  if (resulting_string) {
1079    return this._create_token(TOKEN.RAW, resulting_string);
1080  } else {
1081    return this._create_token(TOKEN.EOF, '');
1082  }
1083};
1084
1085Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
1086  return false;
1087};
1088
1089Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
1090  return false;
1091};
1092
1093Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
1094  return false;
1095};
1096
1097Tokenizer.prototype._create_token = function(type, text) {
1098  var token = new Token(type, text,
1099    this._patterns.whitespace.newline_count,
1100    this._patterns.whitespace.whitespace_before_token);
1101  return token;
1102};
1103
1104Tokenizer.prototype._readWhitespace = function() {
1105  return this._patterns.whitespace.read();
1106};
1107
1108
1109
1110module.exports.Tokenizer = Tokenizer;
1111module.exports.TOKEN = TOKEN;
1112
1113
1114/***/ }),
1115/* 10 */
1116/***/ (function(module) {
1117
1118/*jshint node:true */
1119/*
1120
1121  The MIT License (MIT)
1122
1123  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1124
1125  Permission is hereby granted, free of charge, to any person
1126  obtaining a copy of this software and associated documentation files
1127  (the "Software"), to deal in the Software without restriction,
1128  including without limitation the rights to use, copy, modify, merge,
1129  publish, distribute, sublicense, and/or sell copies of the Software,
1130  and to permit persons to whom the Software is furnished to do so,
1131  subject to the following conditions:
1132
1133  The above copyright notice and this permission notice shall be
1134  included in all copies or substantial portions of the Software.
1135
1136  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1137  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1138  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1139  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1140  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1141  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1142  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1143  SOFTWARE.
1144*/
1145
1146
1147
1148function TokenStream(parent_token) {
1149  // private
1150  this.__tokens = [];
1151  this.__tokens_length = this.__tokens.length;
1152  this.__position = 0;
1153  this.__parent_token = parent_token;
1154}
1155
1156TokenStream.prototype.restart = function() {
1157  this.__position = 0;
1158};
1159
1160TokenStream.prototype.isEmpty = function() {
1161  return this.__tokens_length === 0;
1162};
1163
1164TokenStream.prototype.hasNext = function() {
1165  return this.__position < this.__tokens_length;
1166};
1167
1168TokenStream.prototype.next = function() {
1169  var val = null;
1170  if (this.hasNext()) {
1171    val = this.__tokens[this.__position];
1172    this.__position += 1;
1173  }
1174  return val;
1175};
1176
1177TokenStream.prototype.peek = function(index) {
1178  var val = null;
1179  index = index || 0;
1180  index += this.__position;
1181  if (index >= 0 && index < this.__tokens_length) {
1182    val = this.__tokens[index];
1183  }
1184  return val;
1185};
1186
1187TokenStream.prototype.add = function(token) {
1188  if (this.__parent_token) {
1189    token.parent = this.__parent_token;
1190  }
1191  this.__tokens.push(token);
1192  this.__tokens_length += 1;
1193};
1194
1195module.exports.TokenStream = TokenStream;
1196
1197
1198/***/ }),
1199/* 11 */
1200/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1201
1202/*jshint node:true */
1203/*
1204
1205  The MIT License (MIT)
1206
1207  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1208
1209  Permission is hereby granted, free of charge, to any person
1210  obtaining a copy of this software and associated documentation files
1211  (the "Software"), to deal in the Software without restriction,
1212  including without limitation the rights to use, copy, modify, merge,
1213  publish, distribute, sublicense, and/or sell copies of the Software,
1214  and to permit persons to whom the Software is furnished to do so,
1215  subject to the following conditions:
1216
1217  The above copyright notice and this permission notice shall be
1218  included in all copies or substantial portions of the Software.
1219
1220  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1221  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1222  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1223  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1224  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1225  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1226  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1227  SOFTWARE.
1228*/
1229
1230
1231
1232var Pattern = (__webpack_require__(12).Pattern);
1233
1234function WhitespacePattern(input_scanner, parent) {
1235  Pattern.call(this, input_scanner, parent);
1236  if (parent) {
1237    this._line_regexp = this._input.get_regexp(parent._line_regexp);
1238  } else {
1239    this.__set_whitespace_patterns('', '');
1240  }
1241
1242  this.newline_count = 0;
1243  this.whitespace_before_token = '';
1244}
1245WhitespacePattern.prototype = new Pattern();
1246
1247WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
1248  whitespace_chars += '\\t ';
1249  newline_chars += '\\n\\r';
1250
1251  this._match_pattern = this._input.get_regexp(
1252    '[' + whitespace_chars + newline_chars + ']+', true);
1253  this._newline_regexp = this._input.get_regexp(
1254    '\\r\\n|[' + newline_chars + ']');
1255};
1256
1257WhitespacePattern.prototype.read = function() {
1258  this.newline_count = 0;
1259  this.whitespace_before_token = '';
1260
1261  var resulting_string = this._input.read(this._match_pattern);
1262  if (resulting_string === ' ') {
1263    this.whitespace_before_token = ' ';
1264  } else if (resulting_string) {
1265    var matches = this.__split(this._newline_regexp, resulting_string);
1266    this.newline_count = matches.length - 1;
1267    this.whitespace_before_token = matches[this.newline_count];
1268  }
1269
1270  return resulting_string;
1271};
1272
1273WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
1274  var result = this._create();
1275  result.__set_whitespace_patterns(whitespace_chars, newline_chars);
1276  result._update();
1277  return result;
1278};
1279
1280WhitespacePattern.prototype._create = function() {
1281  return new WhitespacePattern(this._input, this);
1282};
1283
1284WhitespacePattern.prototype.__split = function(regexp, input_string) {
1285  regexp.lastIndex = 0;
1286  var start_index = 0;
1287  var result = [];
1288  var next_match = regexp.exec(input_string);
1289  while (next_match) {
1290    result.push(input_string.substring(start_index, next_match.index));
1291    start_index = next_match.index + next_match[0].length;
1292    next_match = regexp.exec(input_string);
1293  }
1294
1295  if (start_index < input_string.length) {
1296    result.push(input_string.substring(start_index, input_string.length));
1297  } else {
1298    result.push('');
1299  }
1300
1301  return result;
1302};
1303
1304
1305
1306module.exports.WhitespacePattern = WhitespacePattern;
1307
1308
1309/***/ }),
1310/* 12 */
1311/***/ (function(module) {
1312
1313/*jshint node:true */
1314/*
1315
1316  The MIT License (MIT)
1317
1318  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1319
1320  Permission is hereby granted, free of charge, to any person
1321  obtaining a copy of this software and associated documentation files
1322  (the "Software"), to deal in the Software without restriction,
1323  including without limitation the rights to use, copy, modify, merge,
1324  publish, distribute, sublicense, and/or sell copies of the Software,
1325  and to permit persons to whom the Software is furnished to do so,
1326  subject to the following conditions:
1327
1328  The above copyright notice and this permission notice shall be
1329  included in all copies or substantial portions of the Software.
1330
1331  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1332  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1333  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1334  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1335  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1336  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1337  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1338  SOFTWARE.
1339*/
1340
1341
1342
1343function Pattern(input_scanner, parent) {
1344  this._input = input_scanner;
1345  this._starting_pattern = null;
1346  this._match_pattern = null;
1347  this._until_pattern = null;
1348  this._until_after = false;
1349
1350  if (parent) {
1351    this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
1352    this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
1353    this._until_pattern = this._input.get_regexp(parent._until_pattern);
1354    this._until_after = parent._until_after;
1355  }
1356}
1357
1358Pattern.prototype.read = function() {
1359  var result = this._input.read(this._starting_pattern);
1360  if (!this._starting_pattern || result) {
1361    result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
1362  }
1363  return result;
1364};
1365
1366Pattern.prototype.read_match = function() {
1367  return this._input.match(this._match_pattern);
1368};
1369
1370Pattern.prototype.until_after = function(pattern) {
1371  var result = this._create();
1372  result._until_after = true;
1373  result._until_pattern = this._input.get_regexp(pattern);
1374  result._update();
1375  return result;
1376};
1377
1378Pattern.prototype.until = function(pattern) {
1379  var result = this._create();
1380  result._until_after = false;
1381  result._until_pattern = this._input.get_regexp(pattern);
1382  result._update();
1383  return result;
1384};
1385
1386Pattern.prototype.starting_with = function(pattern) {
1387  var result = this._create();
1388  result._starting_pattern = this._input.get_regexp(pattern, true);
1389  result._update();
1390  return result;
1391};
1392
1393Pattern.prototype.matching = function(pattern) {
1394  var result = this._create();
1395  result._match_pattern = this._input.get_regexp(pattern, true);
1396  result._update();
1397  return result;
1398};
1399
1400Pattern.prototype._create = function() {
1401  return new Pattern(this._input, this);
1402};
1403
1404Pattern.prototype._update = function() {};
1405
1406module.exports.Pattern = Pattern;
1407
1408
1409/***/ }),
1410/* 13 */
1411/***/ (function(module) {
1412
1413/*jshint node:true */
1414/*
1415
1416  The MIT License (MIT)
1417
1418  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1419
1420  Permission is hereby granted, free of charge, to any person
1421  obtaining a copy of this software and associated documentation files
1422  (the "Software"), to deal in the Software without restriction,
1423  including without limitation the rights to use, copy, modify, merge,
1424  publish, distribute, sublicense, and/or sell copies of the Software,
1425  and to permit persons to whom the Software is furnished to do so,
1426  subject to the following conditions:
1427
1428  The above copyright notice and this permission notice shall be
1429  included in all copies or substantial portions of the Software.
1430
1431  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1432  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1433  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1434  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1435  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1436  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1437  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1438  SOFTWARE.
1439*/
1440
1441
1442
1443function Directives(start_block_pattern, end_block_pattern) {
1444  start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
1445  end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
1446  this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
1447  this.__directive_pattern = / (\w+)[:](\w+)/g;
1448
1449  this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
1450}
1451
1452Directives.prototype.get_directives = function(text) {
1453  if (!text.match(this.__directives_block_pattern)) {
1454    return null;
1455  }
1456
1457  var directives = {};
1458  this.__directive_pattern.lastIndex = 0;
1459  var directive_match = this.__directive_pattern.exec(text);
1460
1461  while (directive_match) {
1462    directives[directive_match[1]] = directive_match[2];
1463    directive_match = this.__directive_pattern.exec(text);
1464  }
1465
1466  return directives;
1467};
1468
1469Directives.prototype.readIgnored = function(input) {
1470  return input.readUntilAfter(this.__directives_end_ignore_pattern);
1471};
1472
1473
1474module.exports.Directives = Directives;
1475
1476
1477/***/ }),
1478/* 14 */
1479/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1480
1481/*jshint node:true */
1482/*
1483
1484  The MIT License (MIT)
1485
1486  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1487
1488  Permission is hereby granted, free of charge, to any person
1489  obtaining a copy of this software and associated documentation files
1490  (the "Software"), to deal in the Software without restriction,
1491  including without limitation the rights to use, copy, modify, merge,
1492  publish, distribute, sublicense, and/or sell copies of the Software,
1493  and to permit persons to whom the Software is furnished to do so,
1494  subject to the following conditions:
1495
1496  The above copyright notice and this permission notice shall be
1497  included in all copies or substantial portions of the Software.
1498
1499  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1500  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1501  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1502  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1503  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1504  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1505  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1506  SOFTWARE.
1507*/
1508
1509
1510
1511var Pattern = (__webpack_require__(12).Pattern);
1512
1513
1514var template_names = {
1515  django: false,
1516  erb: false,
1517  handlebars: false,
1518  php: false,
1519  smarty: false,
1520  angular: false
1521};
1522
1523// This lets templates appear anywhere we would do a readUntil
1524// The cost is higher but it is pay to play.
1525function TemplatablePattern(input_scanner, parent) {
1526  Pattern.call(this, input_scanner, parent);
1527  this.__template_pattern = null;
1528  this._disabled = Object.assign({}, template_names);
1529  this._excluded = Object.assign({}, template_names);
1530
1531  if (parent) {
1532    this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
1533    this._excluded = Object.assign(this._excluded, parent._excluded);
1534    this._disabled = Object.assign(this._disabled, parent._disabled);
1535  }
1536  var pattern = new Pattern(input_scanner);
1537  this.__patterns = {
1538    handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
1539    handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
1540    handlebars: pattern.starting_with(/{{/).until_after(/}}/),
1541    php: pattern.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
1542    erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
1543    // django coflicts with handlebars a bit.
1544    django: pattern.starting_with(/{%/).until_after(/%}/),
1545    django_value: pattern.starting_with(/{{/).until_after(/}}/),
1546    django_comment: pattern.starting_with(/{#/).until_after(/#}/),
1547    smarty: pattern.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
1548    smarty_comment: pattern.starting_with(/{\*/).until_after(/\*}/),
1549    smarty_literal: pattern.starting_with(/{literal}/).until_after(/{\/literal}/)
1550  };
1551}
1552TemplatablePattern.prototype = new Pattern();
1553
1554TemplatablePattern.prototype._create = function() {
1555  return new TemplatablePattern(this._input, this);
1556};
1557
1558TemplatablePattern.prototype._update = function() {
1559  this.__set_templated_pattern();
1560};
1561
1562TemplatablePattern.prototype.disable = function(language) {
1563  var result = this._create();
1564  result._disabled[language] = true;
1565  result._update();
1566  return result;
1567};
1568
1569TemplatablePattern.prototype.read_options = function(options) {
1570  var result = this._create();
1571  for (var language in template_names) {
1572    result._disabled[language] = options.templating.indexOf(language) === -1;
1573  }
1574  result._update();
1575  return result;
1576};
1577
1578TemplatablePattern.prototype.exclude = function(language) {
1579  var result = this._create();
1580  result._excluded[language] = true;
1581  result._update();
1582  return result;
1583};
1584
1585TemplatablePattern.prototype.read = function() {
1586  var result = '';
1587  if (this._match_pattern) {
1588    result = this._input.read(this._starting_pattern);
1589  } else {
1590    result = this._input.read(this._starting_pattern, this.__template_pattern);
1591  }
1592  var next = this._read_template();
1593  while (next) {
1594    if (this._match_pattern) {
1595      next += this._input.read(this._match_pattern);
1596    } else {
1597      next += this._input.readUntil(this.__template_pattern);
1598    }
1599    result += next;
1600    next = this._read_template();
1601  }
1602
1603  if (this._until_after) {
1604    result += this._input.readUntilAfter(this._until_pattern);
1605  }
1606  return result;
1607};
1608
1609TemplatablePattern.prototype.__set_templated_pattern = function() {
1610  var items = [];
1611
1612  if (!this._disabled.php) {
1613    items.push(this.__patterns.php._starting_pattern.source);
1614  }
1615  if (!this._disabled.handlebars) {
1616    items.push(this.__patterns.handlebars._starting_pattern.source);
1617  }
1618  if (!this._disabled.angular) {
1619    // Handlebars ('{{' and '}}') are also special tokens in Angular)
1620    items.push(this.__patterns.handlebars._starting_pattern.source);
1621  }
1622  if (!this._disabled.erb) {
1623    items.push(this.__patterns.erb._starting_pattern.source);
1624  }
1625  if (!this._disabled.django) {
1626    items.push(this.__patterns.django._starting_pattern.source);
1627    // The starting pattern for django is more complex because it has different
1628    // patterns for value, comment, and other sections
1629    items.push(this.__patterns.django_value._starting_pattern.source);
1630    items.push(this.__patterns.django_comment._starting_pattern.source);
1631  }
1632  if (!this._disabled.smarty) {
1633    items.push(this.__patterns.smarty._starting_pattern.source);
1634  }
1635
1636  if (this._until_pattern) {
1637    items.push(this._until_pattern.source);
1638  }
1639  this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
1640};
1641
1642TemplatablePattern.prototype._read_template = function() {
1643  var resulting_string = '';
1644  var c = this._input.peek();
1645  if (c === '<') {
1646    var peek1 = this._input.peek(1);
1647    //if we're in a comment, do something special
1648    // We treat all comments as literals, even more than preformatted tags
1649    // we just look for the appropriate close tag
1650    if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
1651      resulting_string = resulting_string ||
1652        this.__patterns.php.read();
1653    }
1654    if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
1655      resulting_string = resulting_string ||
1656        this.__patterns.erb.read();
1657    }
1658  } else if (c === '{') {
1659    if (!this._disabled.handlebars && !this._excluded.handlebars) {
1660      resulting_string = resulting_string ||
1661        this.__patterns.handlebars_comment.read();
1662      resulting_string = resulting_string ||
1663        this.__patterns.handlebars_unescaped.read();
1664      resulting_string = resulting_string ||
1665        this.__patterns.handlebars.read();
1666    }
1667    if (!this._disabled.django) {
1668      // django coflicts with handlebars a bit.
1669      if (!this._excluded.django && !this._excluded.handlebars) {
1670        resulting_string = resulting_string ||
1671          this.__patterns.django_value.read();
1672      }
1673      if (!this._excluded.django) {
1674        resulting_string = resulting_string ||
1675          this.__patterns.django_comment.read();
1676        resulting_string = resulting_string ||
1677          this.__patterns.django.read();
1678      }
1679    }
1680    if (!this._disabled.smarty) {
1681      // smarty cannot be enabled with django or handlebars enabled
1682      if (this._disabled.django && this._disabled.handlebars) {
1683        resulting_string = resulting_string ||
1684          this.__patterns.smarty_comment.read();
1685        resulting_string = resulting_string ||
1686          this.__patterns.smarty_literal.read();
1687        resulting_string = resulting_string ||
1688          this.__patterns.smarty.read();
1689      }
1690    }
1691  }
1692  return resulting_string;
1693};
1694
1695
1696module.exports.TemplatablePattern = TemplatablePattern;
1697
1698
1699/***/ }),
1700/* 15 */,
1701/* 16 */,
1702/* 17 */,
1703/* 18 */
1704/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1705
1706/*jshint node:true */
1707/*
1708
1709  The MIT License (MIT)
1710
1711  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1712
1713  Permission is hereby granted, free of charge, to any person
1714  obtaining a copy of this software and associated documentation files
1715  (the "Software"), to deal in the Software without restriction,
1716  including without limitation the rights to use, copy, modify, merge,
1717  publish, distribute, sublicense, and/or sell copies of the Software,
1718  and to permit persons to whom the Software is furnished to do so,
1719  subject to the following conditions:
1720
1721  The above copyright notice and this permission notice shall be
1722  included in all copies or substantial portions of the Software.
1723
1724  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1725  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1726  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1727  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1728  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1729  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1730  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1731  SOFTWARE.
1732*/
1733
1734
1735
1736var Beautifier = (__webpack_require__(19).Beautifier),
1737  Options = (__webpack_require__(20).Options);
1738
1739function style_html(html_source, options, js_beautify, css_beautify) {
1740  var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify);
1741  return beautifier.beautify();
1742}
1743
1744module.exports = style_html;
1745module.exports.defaultOptions = function() {
1746  return new Options();
1747};
1748
1749
1750/***/ }),
1751/* 19 */
1752/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1753
1754/*jshint node:true */
1755/*
1756
1757  The MIT License (MIT)
1758
1759  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1760
1761  Permission is hereby granted, free of charge, to any person
1762  obtaining a copy of this software and associated documentation files
1763  (the "Software"), to deal in the Software without restriction,
1764  including without limitation the rights to use, copy, modify, merge,
1765  publish, distribute, sublicense, and/or sell copies of the Software,
1766  and to permit persons to whom the Software is furnished to do so,
1767  subject to the following conditions:
1768
1769  The above copyright notice and this permission notice shall be
1770  included in all copies or substantial portions of the Software.
1771
1772  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1773  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1774  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1775  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1776  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1777  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1778  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1779  SOFTWARE.
1780*/
1781
1782
1783
1784var Options = (__webpack_require__(20).Options);
1785var Output = (__webpack_require__(2).Output);
1786var Tokenizer = (__webpack_require__(21).Tokenizer);
1787var TOKEN = (__webpack_require__(21).TOKEN);
1788
1789var lineBreak = /\r\n|[\r\n]/;
1790var allLineBreaks = /\r\n|[\r\n]/g;
1791
1792var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
1793
1794  this.indent_level = 0;
1795  this.alignment_size = 0;
1796  this.max_preserve_newlines = options.max_preserve_newlines;
1797  this.preserve_newlines = options.preserve_newlines;
1798
1799  this._output = new Output(options, base_indent_string);
1800
1801};
1802
1803Printer.prototype.current_line_has_match = function(pattern) {
1804  return this._output.current_line.has_match(pattern);
1805};
1806
1807Printer.prototype.set_space_before_token = function(value, non_breaking) {
1808  this._output.space_before_token = value;
1809  this._output.non_breaking_space = non_breaking;
1810};
1811
1812Printer.prototype.set_wrap_point = function() {
1813  this._output.set_indent(this.indent_level, this.alignment_size);
1814  this._output.set_wrap_point();
1815};
1816
1817
1818Printer.prototype.add_raw_token = function(token) {
1819  this._output.add_raw_token(token);
1820};
1821
1822Printer.prototype.print_preserved_newlines = function(raw_token) {
1823  var newlines = 0;
1824  if (raw_token.type !== TOKEN.TEXT && raw_token.previous.type !== TOKEN.TEXT) {
1825    newlines = raw_token.newlines ? 1 : 0;
1826  }
1827
1828  if (this.preserve_newlines) {
1829    newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
1830  }
1831  for (var n = 0; n < newlines; n++) {
1832    this.print_newline(n > 0);
1833  }
1834
1835  return newlines !== 0;
1836};
1837
1838Printer.prototype.traverse_whitespace = function(raw_token) {
1839  if (raw_token.whitespace_before || raw_token.newlines) {
1840    if (!this.print_preserved_newlines(raw_token)) {
1841      this._output.space_before_token = true;
1842    }
1843    return true;
1844  }
1845  return false;
1846};
1847
1848Printer.prototype.previous_token_wrapped = function() {
1849  return this._output.previous_token_wrapped;
1850};
1851
1852Printer.prototype.print_newline = function(force) {
1853  this._output.add_new_line(force);
1854};
1855
1856Printer.prototype.print_token = function(token) {
1857  if (token.text) {
1858    this._output.set_indent(this.indent_level, this.alignment_size);
1859    this._output.add_token(token.text);
1860  }
1861};
1862
1863Printer.prototype.indent = function() {
1864  this.indent_level++;
1865};
1866
1867Printer.prototype.deindent = function() {
1868  if (this.indent_level > 0) {
1869    this.indent_level--;
1870    this._output.set_indent(this.indent_level, this.alignment_size);
1871  }
1872};
1873
1874Printer.prototype.get_full_indent = function(level) {
1875  level = this.indent_level + (level || 0);
1876  if (level < 1) {
1877    return '';
1878  }
1879
1880  return this._output.get_indent_string(level);
1881};
1882
1883var get_type_attribute = function(start_token) {
1884  var result = null;
1885  var raw_token = start_token.next;
1886
1887  // Search attributes for a type attribute
1888  while (raw_token.type !== TOKEN.EOF && start_token.closed !== raw_token) {
1889    if (raw_token.type === TOKEN.ATTRIBUTE && raw_token.text === 'type') {
1890      if (raw_token.next && raw_token.next.type === TOKEN.EQUALS &&
1891        raw_token.next.next && raw_token.next.next.type === TOKEN.VALUE) {
1892        result = raw_token.next.next.text;
1893      }
1894      break;
1895    }
1896    raw_token = raw_token.next;
1897  }
1898
1899  return result;
1900};
1901
1902var get_custom_beautifier_name = function(tag_check, raw_token) {
1903  var typeAttribute = null;
1904  var result = null;
1905
1906  if (!raw_token.closed) {
1907    return null;
1908  }
1909
1910  if (tag_check === 'script') {
1911    typeAttribute = 'text/javascript';
1912  } else if (tag_check === 'style') {
1913    typeAttribute = 'text/css';
1914  }
1915
1916  typeAttribute = get_type_attribute(raw_token) || typeAttribute;
1917
1918  // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
1919  // For those without a type attribute use default;
1920  if (typeAttribute.search('text/css') > -1) {
1921    result = 'css';
1922  } else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
1923    result = 'javascript';
1924  } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
1925    result = 'html';
1926  } else if (typeAttribute.search(/test\/null/) > -1) {
1927    // Test only mime-type for testing the beautifier when null is passed as beautifing function
1928    result = 'null';
1929  }
1930
1931  return result;
1932};
1933
1934function in_array(what, arr) {
1935  return arr.indexOf(what) !== -1;
1936}
1937
1938function TagFrame(parent, parser_token, indent_level) {
1939  this.parent = parent || null;
1940  this.tag = parser_token ? parser_token.tag_name : '';
1941  this.indent_level = indent_level || 0;
1942  this.parser_token = parser_token || null;
1943}
1944
1945function TagStack(printer) {
1946  this._printer = printer;
1947  this._current_frame = null;
1948}
1949
1950TagStack.prototype.get_parser_token = function() {
1951  return this._current_frame ? this._current_frame.parser_token : null;
1952};
1953
1954TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
1955  var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
1956  this._current_frame = new_frame;
1957};
1958
1959TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
1960  var parser_token = null;
1961
1962  if (frame) {
1963    parser_token = frame.parser_token;
1964    this._printer.indent_level = frame.indent_level;
1965    this._current_frame = frame.parent;
1966  }
1967
1968  return parser_token;
1969};
1970
1971TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
1972  var frame = this._current_frame;
1973
1974  while (frame) { //till we reach '' (the initial value);
1975    if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
1976      break;
1977    } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
1978      frame = null;
1979      break;
1980    }
1981    frame = frame.parent;
1982  }
1983
1984  return frame;
1985};
1986
1987TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
1988  var frame = this._get_frame([tag], stop_list);
1989  return this._try_pop_frame(frame);
1990};
1991
1992TagStack.prototype.indent_to_tag = function(tag_list) {
1993  var frame = this._get_frame(tag_list);
1994  if (frame) {
1995    this._printer.indent_level = frame.indent_level;
1996  }
1997};
1998
1999function Beautifier(source_text, options, js_beautify, css_beautify) {
2000  //Wrapper function to invoke all the necessary constructors and deal with the output.
2001  this._source_text = source_text || '';
2002  options = options || {};
2003  this._js_beautify = js_beautify;
2004  this._css_beautify = css_beautify;
2005  this._tag_stack = null;
2006
2007  // Allow the setting of language/file-type specific options
2008  // with inheritance of overall settings
2009  var optionHtml = new Options(options, 'html');
2010
2011  this._options = optionHtml;
2012
2013  this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
2014  this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
2015  this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
2016  this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
2017  this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
2018  this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
2019}
2020
2021Beautifier.prototype.beautify = function() {
2022
2023  // if disabled, return the input unchanged.
2024  if (this._options.disabled) {
2025    return this._source_text;
2026  }
2027
2028  var source_text = this._source_text;
2029  var eol = this._options.eol;
2030  if (this._options.eol === 'auto') {
2031    eol = '\n';
2032    if (source_text && lineBreak.test(source_text)) {
2033      eol = source_text.match(lineBreak)[0];
2034    }
2035  }
2036
2037  // HACK: newline parsing inconsistent. This brute force normalizes the input.
2038  source_text = source_text.replace(allLineBreaks, '\n');
2039
2040  var baseIndentString = source_text.match(/^[\t ]*/)[0];
2041
2042  var last_token = {
2043    text: '',
2044    type: ''
2045  };
2046
2047  var last_tag_token = new TagOpenParserToken(this._options);
2048
2049  var printer = new Printer(this._options, baseIndentString);
2050  var tokens = new Tokenizer(source_text, this._options).tokenize();
2051
2052  this._tag_stack = new TagStack(printer);
2053
2054  var parser_token = null;
2055  var raw_token = tokens.next();
2056  while (raw_token.type !== TOKEN.EOF) {
2057
2058    if (raw_token.type === TOKEN.TAG_OPEN || raw_token.type === TOKEN.COMMENT) {
2059      parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token, tokens);
2060      last_tag_token = parser_token;
2061    } else if ((raw_token.type === TOKEN.ATTRIBUTE || raw_token.type === TOKEN.EQUALS || raw_token.type === TOKEN.VALUE) ||
2062      (raw_token.type === TOKEN.TEXT && !last_tag_token.tag_complete)) {
2063      parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, last_token);
2064    } else if (raw_token.type === TOKEN.TAG_CLOSE) {
2065      parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
2066    } else if (raw_token.type === TOKEN.TEXT) {
2067      parser_token = this._handle_text(printer, raw_token, last_tag_token);
2068    } else if (raw_token.type === TOKEN.CONTROL_FLOW_OPEN) {
2069      parser_token = this._handle_control_flow_open(printer, raw_token);
2070    } else if (raw_token.type === TOKEN.CONTROL_FLOW_CLOSE) {
2071      parser_token = this._handle_control_flow_close(printer, raw_token);
2072    } else {
2073      // This should never happen, but if it does. Print the raw token
2074      printer.add_raw_token(raw_token);
2075    }
2076
2077    last_token = parser_token;
2078
2079    raw_token = tokens.next();
2080  }
2081  var sweet_code = printer._output.get_code(eol);
2082
2083  return sweet_code;
2084};
2085
2086Beautifier.prototype._handle_control_flow_open = function(printer, raw_token) {
2087  var parser_token = {
2088    text: raw_token.text,
2089    type: raw_token.type
2090  };
2091  printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
2092  if (raw_token.newlines) {
2093    printer.print_preserved_newlines(raw_token);
2094  } else {
2095    printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
2096  }
2097  printer.print_token(raw_token);
2098  printer.indent();
2099  return parser_token;
2100};
2101
2102Beautifier.prototype._handle_control_flow_close = function(printer, raw_token) {
2103  var parser_token = {
2104    text: raw_token.text,
2105    type: raw_token.type
2106  };
2107
2108  printer.deindent();
2109  if (raw_token.newlines) {
2110    printer.print_preserved_newlines(raw_token);
2111  } else {
2112    printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
2113  }
2114  printer.print_token(raw_token);
2115  return parser_token;
2116};
2117
2118Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
2119  var parser_token = {
2120    text: raw_token.text,
2121    type: raw_token.type
2122  };
2123  printer.alignment_size = 0;
2124  last_tag_token.tag_complete = true;
2125
2126  printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
2127  if (last_tag_token.is_unformatted) {
2128    printer.add_raw_token(raw_token);
2129  } else {
2130    if (last_tag_token.tag_start_char === '<') {
2131      printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
2132      if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
2133        printer.print_newline(false);
2134      }
2135    }
2136    printer.print_token(raw_token);
2137
2138  }
2139
2140  if (last_tag_token.indent_content &&
2141    !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
2142    printer.indent();
2143
2144    // only indent once per opened tag
2145    last_tag_token.indent_content = false;
2146  }
2147
2148  if (!last_tag_token.is_inline_element &&
2149    !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
2150    printer.set_wrap_point();
2151  }
2152
2153  return parser_token;
2154};
2155
2156Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, last_token) {
2157  var wrapped = last_tag_token.has_wrapped_attrs;
2158  var parser_token = {
2159    text: raw_token.text,
2160    type: raw_token.type
2161  };
2162
2163  printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
2164  if (last_tag_token.is_unformatted) {
2165    printer.add_raw_token(raw_token);
2166  } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN.TEXT) {
2167    // For the insides of handlebars allow newlines or a single space between open and contents
2168    if (printer.print_preserved_newlines(raw_token)) {
2169      raw_token.newlines = 0;
2170      printer.add_raw_token(raw_token);
2171    } else {
2172      printer.print_token(raw_token);
2173    }
2174  } else {
2175    if (raw_token.type === TOKEN.ATTRIBUTE) {
2176      printer.set_space_before_token(true);
2177    } else if (raw_token.type === TOKEN.EQUALS) { //no space before =
2178      printer.set_space_before_token(false);
2179    } else if (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) { //no space before value
2180      printer.set_space_before_token(false);
2181    }
2182
2183    if (raw_token.type === TOKEN.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
2184      if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
2185        printer.traverse_whitespace(raw_token);
2186        wrapped = wrapped || raw_token.newlines !== 0;
2187      }
2188
2189      // Wrap for 'force' options, and if the number of attributes is at least that specified in 'wrap_attributes_min_attrs':
2190      // 1. always wrap the second and beyond attributes
2191      // 2. wrap the first attribute only if 'force-expand-multiline' is specified
2192      if (this._is_wrap_attributes_force &&
2193        last_tag_token.attr_count >= this._options.wrap_attributes_min_attrs &&
2194        (last_token.type !== TOKEN.TAG_OPEN || // ie. second attribute and beyond
2195          this._is_wrap_attributes_force_expand_multiline)) {
2196        printer.print_newline(false);
2197        wrapped = true;
2198      }
2199    }
2200    printer.print_token(raw_token);
2201    wrapped = wrapped || printer.previous_token_wrapped();
2202    last_tag_token.has_wrapped_attrs = wrapped;
2203  }
2204  return parser_token;
2205};
2206
2207Beautifier.prototype._handle_text = function(printer, raw_token, last_tag_token) {
2208  var parser_token = {
2209    text: raw_token.text,
2210    type: 'TK_CONTENT'
2211  };
2212  if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
2213    this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
2214  } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
2215    printer.add_raw_token(raw_token);
2216  } else {
2217    printer.traverse_whitespace(raw_token);
2218    printer.print_token(raw_token);
2219  }
2220  return parser_token;
2221};
2222
2223Beautifier.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
2224  var local = this;
2225  if (raw_token.text !== '') {
2226
2227    var text = raw_token.text,
2228      _beautifier,
2229      script_indent_level = 1,
2230      pre = '',
2231      post = '';
2232    if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
2233      _beautifier = this._js_beautify;
2234    } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
2235      _beautifier = this._css_beautify;
2236    } else if (last_tag_token.custom_beautifier_name === 'html') {
2237      _beautifier = function(html_source, options) {
2238        var beautifier = new Beautifier(html_source, options, local._js_beautify, local._css_beautify);
2239        return beautifier.beautify();
2240      };
2241    }
2242
2243    if (this._options.indent_scripts === "keep") {
2244      script_indent_level = 0;
2245    } else if (this._options.indent_scripts === "separate") {
2246      script_indent_level = -printer.indent_level;
2247    }
2248
2249    var indentation = printer.get_full_indent(script_indent_level);
2250
2251    // if there is at least one empty line at the end of this text, strip it
2252    // we'll be adding one back after the text but before the containing tag.
2253    text = text.replace(/\n[ \t]*$/, '');
2254
2255    // Handle the case where content is wrapped in a comment or cdata.
2256    if (last_tag_token.custom_beautifier_name !== 'html' &&
2257      text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
2258      var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
2259
2260      // if we start to wrap but don't finish, print raw
2261      if (!matched) {
2262        printer.add_raw_token(raw_token);
2263        return;
2264      }
2265
2266      pre = indentation + matched[1] + '\n';
2267      text = matched[4];
2268      if (matched[5]) {
2269        post = indentation + matched[5];
2270      }
2271
2272      // if there is at least one empty line at the end of this text, strip it
2273      // we'll be adding one back after the text but before the containing tag.
2274      text = text.replace(/\n[ \t]*$/, '');
2275
2276      if (matched[2] || matched[3].indexOf('\n') !== -1) {
2277        // if the first line of the non-comment text has spaces
2278        // use that as the basis for indenting in null case.
2279        matched = matched[3].match(/[ \t]+$/);
2280        if (matched) {
2281          raw_token.whitespace_before = matched[0];
2282        }
2283      }
2284    }
2285
2286    if (text) {
2287      if (_beautifier) {
2288
2289        // call the Beautifier if avaliable
2290        var Child_options = function() {
2291          this.eol = '\n';
2292        };
2293        Child_options.prototype = this._options.raw_options;
2294        var child_options = new Child_options();
2295        text = _beautifier(indentation + text, child_options);
2296      } else {
2297        // simply indent the string otherwise
2298        var white = raw_token.whitespace_before;
2299        if (white) {
2300          text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
2301        }
2302
2303        text = indentation + text.replace(/\n/g, '\n' + indentation);
2304      }
2305    }
2306
2307    if (pre) {
2308      if (!text) {
2309        text = pre + post;
2310      } else {
2311        text = pre + text + '\n' + post;
2312      }
2313    }
2314
2315    printer.print_newline(false);
2316    if (text) {
2317      raw_token.text = text;
2318      raw_token.whitespace_before = '';
2319      raw_token.newlines = 0;
2320      printer.add_raw_token(raw_token);
2321      printer.print_newline(true);
2322    }
2323  }
2324};
2325
2326Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token, tokens) {
2327  var parser_token = this._get_tag_open_token(raw_token);
2328
2329  if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
2330    !last_tag_token.is_empty_element &&
2331    raw_token.type === TOKEN.TAG_OPEN && !parser_token.is_start_tag) {
2332    // End element tags for unformatted or content_unformatted elements
2333    // are printed raw to keep any newlines inside them exactly the same.
2334    printer.add_raw_token(raw_token);
2335    parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
2336  } else {
2337    printer.traverse_whitespace(raw_token);
2338    this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
2339    if (!parser_token.is_inline_element) {
2340      printer.set_wrap_point();
2341    }
2342    printer.print_token(raw_token);
2343  }
2344
2345  // count the number of attributes
2346  if (parser_token.is_start_tag && this._is_wrap_attributes_force) {
2347    var peek_index = 0;
2348    var peek_token;
2349    do {
2350      peek_token = tokens.peek(peek_index);
2351      if (peek_token.type === TOKEN.ATTRIBUTE) {
2352        parser_token.attr_count += 1;
2353      }
2354      peek_index += 1;
2355    } while (peek_token.type !== TOKEN.EOF && peek_token.type !== TOKEN.TAG_CLOSE);
2356  }
2357
2358  //indent attributes an auto, forced, aligned or forced-align line-wrap
2359  if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
2360    parser_token.alignment_size = raw_token.text.length + 1;
2361  }
2362
2363  if (!parser_token.tag_complete && !parser_token.is_unformatted) {
2364    printer.alignment_size = parser_token.alignment_size;
2365  }
2366
2367  return parser_token;
2368};
2369
2370var TagOpenParserToken = function(options, parent, raw_token) {
2371  this.parent = parent || null;
2372  this.text = '';
2373  this.type = 'TK_TAG_OPEN';
2374  this.tag_name = '';
2375  this.is_inline_element = false;
2376  this.is_unformatted = false;
2377  this.is_content_unformatted = false;
2378  this.is_empty_element = false;
2379  this.is_start_tag = false;
2380  this.is_end_tag = false;
2381  this.indent_content = false;
2382  this.multiline_content = false;
2383  this.custom_beautifier_name = null;
2384  this.start_tag_token = null;
2385  this.attr_count = 0;
2386  this.has_wrapped_attrs = false;
2387  this.alignment_size = 0;
2388  this.tag_complete = false;
2389  this.tag_start_char = '';
2390  this.tag_check = '';
2391
2392  if (!raw_token) {
2393    this.tag_complete = true;
2394  } else {
2395    var tag_check_match;
2396
2397    this.tag_start_char = raw_token.text[0];
2398    this.text = raw_token.text;
2399
2400    if (this.tag_start_char === '<') {
2401      tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
2402      this.tag_check = tag_check_match ? tag_check_match[1] : '';
2403    } else {
2404      tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/);
2405      this.tag_check = tag_check_match ? tag_check_match[1] : '';
2406
2407      // handle "{{#> myPartial}}" or "{{~#> myPartial}}"
2408      if ((raw_token.text.startsWith('{{#>') || raw_token.text.startsWith('{{~#>')) && this.tag_check[0] === '>') {
2409        if (this.tag_check === '>' && raw_token.next !== null) {
2410          this.tag_check = raw_token.next.text.split(' ')[0];
2411        } else {
2412          this.tag_check = raw_token.text.split('>')[1];
2413        }
2414      }
2415    }
2416
2417    this.tag_check = this.tag_check.toLowerCase();
2418
2419    if (raw_token.type === TOKEN.COMMENT) {
2420      this.tag_complete = true;
2421    }
2422
2423    this.is_start_tag = this.tag_check.charAt(0) !== '/';
2424    this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
2425    this.is_end_tag = !this.is_start_tag ||
2426      (raw_token.closed && raw_token.closed.text === '/>');
2427
2428    // if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2
2429    var handlebar_starts = 2;
2430    if (this.tag_start_char === '{' && this.text.length >= 3) {
2431      if (this.text.charAt(2) === '~') {
2432        handlebar_starts = 3;
2433      }
2434    }
2435
2436    // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
2437    // if they start with # or ^, they are still considered single tags if indenting of handlebars is set to false
2438    this.is_end_tag = this.is_end_tag ||
2439      (this.tag_start_char === '{' && (!options.indent_handlebars || this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts)))));
2440  }
2441};
2442
2443Beautifier.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
2444  var parser_token = new TagOpenParserToken(this._options, this._tag_stack.get_parser_token(), raw_token);
2445
2446  parser_token.alignment_size = this._options.wrap_attributes_indent_size;
2447
2448  parser_token.is_end_tag = parser_token.is_end_tag ||
2449    in_array(parser_token.tag_check, this._options.void_elements);
2450
2451  parser_token.is_empty_element = parser_token.tag_complete ||
2452    (parser_token.is_start_tag && parser_token.is_end_tag);
2453
2454  parser_token.is_unformatted = !parser_token.tag_complete && in_array(parser_token.tag_check, this._options.unformatted);
2455  parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array(parser_token.tag_check, this._options.content_unformatted);
2456  parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || (this._options.inline_custom_elements && parser_token.tag_name.includes("-")) || parser_token.tag_start_char === '{';
2457
2458  return parser_token;
2459};
2460
2461Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
2462
2463  if (!parser_token.is_empty_element) {
2464    if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
2465      parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
2466    } else { // it's a start-tag
2467      // check if this tag is starting an element that has optional end element
2468      // and do an ending needed
2469      if (this._do_optional_end_element(parser_token)) {
2470        if (!parser_token.is_inline_element) {
2471          printer.print_newline(false);
2472        }
2473      }
2474
2475      this._tag_stack.record_tag(parser_token); //push it on the tag stack
2476
2477      if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
2478        !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
2479        parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
2480      }
2481    }
2482  }
2483
2484  if (in_array(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
2485    printer.print_newline(false);
2486    if (!printer._output.just_added_blankline()) {
2487      printer.print_newline(true);
2488    }
2489  }
2490
2491  if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
2492
2493    // if you hit an else case, reset the indent level if you are inside an:
2494    // 'if', 'unless', or 'each' block.
2495    if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
2496      this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
2497      parser_token.indent_content = true;
2498      // Don't add a newline if opening {{#if}} tag is on the current line
2499      var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
2500      if (!foundIfOnCurrentLine) {
2501        printer.print_newline(false);
2502      }
2503    }
2504
2505    // Don't add a newline before elements that should remain where they are.
2506    if (parser_token.tag_name === '!--' && last_token.type === TOKEN.TAG_CLOSE &&
2507      last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) {
2508      //Do nothing. Leave comments on same line.
2509    } else {
2510      if (!(parser_token.is_inline_element || parser_token.is_unformatted)) {
2511        printer.print_newline(false);
2512      }
2513      this._calcluate_parent_multiline(printer, parser_token);
2514    }
2515  } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
2516    var do_end_expand = false;
2517
2518    // deciding whether a block is multiline should not be this hard
2519    do_end_expand = parser_token.start_tag_token && parser_token.start_tag_token.multiline_content;
2520    do_end_expand = do_end_expand || (!parser_token.is_inline_element &&
2521      !(last_tag_token.is_inline_element || last_tag_token.is_unformatted) &&
2522      !(last_token.type === TOKEN.TAG_CLOSE && parser_token.start_tag_token === last_tag_token) &&
2523      last_token.type !== 'TK_CONTENT'
2524    );
2525
2526    if (parser_token.is_content_unformatted || parser_token.is_unformatted) {
2527      do_end_expand = false;
2528    }
2529
2530    if (do_end_expand) {
2531      printer.print_newline(false);
2532    }
2533  } else { // it's a start-tag
2534    parser_token.indent_content = !parser_token.custom_beautifier_name;
2535
2536    if (parser_token.tag_start_char === '<') {
2537      if (parser_token.tag_name === 'html') {
2538        parser_token.indent_content = this._options.indent_inner_html;
2539      } else if (parser_token.tag_name === 'head') {
2540        parser_token.indent_content = this._options.indent_head_inner_html;
2541      } else if (parser_token.tag_name === 'body') {
2542        parser_token.indent_content = this._options.indent_body_inner_html;
2543      }
2544    }
2545
2546    if (!(parser_token.is_inline_element || parser_token.is_unformatted) &&
2547      (last_token.type !== 'TK_CONTENT' || parser_token.is_content_unformatted)) {
2548      printer.print_newline(false);
2549    }
2550
2551    this._calcluate_parent_multiline(printer, parser_token);
2552  }
2553};
2554
2555Beautifier.prototype._calcluate_parent_multiline = function(printer, parser_token) {
2556  if (parser_token.parent && printer._output.just_added_newline() &&
2557    !((parser_token.is_inline_element || parser_token.is_unformatted) && parser_token.parent.is_inline_element)) {
2558    parser_token.parent.multiline_content = true;
2559  }
2560};
2561
2562//To be used for <p> tag special case:
2563var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
2564var p_parent_excludes = ['a', 'audio', 'del', 'ins', 'map', 'noscript', 'video'];
2565
2566Beautifier.prototype._do_optional_end_element = function(parser_token) {
2567  var result = null;
2568  // NOTE: cases of "if there is no more content in the parent element"
2569  // are handled automatically by the beautifier.
2570  // It assumes parent or ancestor close tag closes all children.
2571  // https://www.w3.org/TR/html5/syntax.html#optional-tags
2572  if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
2573    return;
2574
2575  }
2576
2577  if (parser_token.tag_name === 'body') {
2578    // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
2579    result = result || this._tag_stack.try_pop('head');
2580
2581    //} else if (parser_token.tag_name === 'body') {
2582    // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
2583
2584  } else if (parser_token.tag_name === 'li') {
2585    // 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.
2586    result = result || this._tag_stack.try_pop('li', ['ol', 'ul', 'menu']);
2587
2588  } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
2589    // 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.
2590    // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
2591    result = result || this._tag_stack.try_pop('dt', ['dl']);
2592    result = result || this._tag_stack.try_pop('dd', ['dl']);
2593
2594
2595  } else if (parser_token.parent.tag_name === 'p' && p_closers.indexOf(parser_token.tag_name) !== -1) {
2596    // IMPORTANT: this else-if works because p_closers has no overlap with any other element we look for in this method
2597    // 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.
2598    // To do this right, this needs to be coded as an inclusion of the inverse of the exclusion above.
2599    // But to start with (if we ignore "autonomous custom elements") the exclusion would be fine.
2600    var p_parent = parser_token.parent.parent;
2601    if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
2602      result = result || this._tag_stack.try_pop('p');
2603    }
2604  } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
2605    // 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.
2606    // 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.
2607    result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
2608    result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
2609
2610  } else if (parser_token.tag_name === 'optgroup') {
2611    // 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.
2612    // 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.
2613    result = result || this._tag_stack.try_pop('optgroup', ['select']);
2614    //result = result || this._tag_stack.try_pop('option', ['select']);
2615
2616  } else if (parser_token.tag_name === 'option') {
2617    // 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.
2618    result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
2619
2620  } else if (parser_token.tag_name === 'colgroup') {
2621    // 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.
2622    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2623    result = result || this._tag_stack.try_pop('caption', ['table']);
2624
2625  } else if (parser_token.tag_name === 'thead') {
2626    // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
2627    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2628    result = result || this._tag_stack.try_pop('caption', ['table']);
2629    result = result || this._tag_stack.try_pop('colgroup', ['table']);
2630
2631    //} else if (parser_token.tag_name === 'caption') {
2632    // 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.
2633
2634  } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
2635    // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
2636    // 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.
2637    // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
2638    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2639    result = result || this._tag_stack.try_pop('caption', ['table']);
2640    result = result || this._tag_stack.try_pop('colgroup', ['table']);
2641    result = result || this._tag_stack.try_pop('thead', ['table']);
2642    result = result || this._tag_stack.try_pop('tbody', ['table']);
2643
2644    //} else if (parser_token.tag_name === 'tfoot') {
2645    // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
2646
2647  } else if (parser_token.tag_name === 'tr') {
2648    // 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.
2649    // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
2650    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2651    result = result || this._tag_stack.try_pop('caption', ['table']);
2652    result = result || this._tag_stack.try_pop('colgroup', ['table']);
2653    result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
2654
2655  } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
2656    // 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.
2657    // 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.
2658    result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
2659    result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
2660  }
2661
2662  // Start element omission not handled currently
2663  // 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.
2664  // 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.)
2665  // 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.)
2666
2667  // Fix up the parent of the parser token
2668  parser_token.parent = this._tag_stack.get_parser_token();
2669
2670  return result;
2671};
2672
2673module.exports.Beautifier = Beautifier;
2674
2675
2676/***/ }),
2677/* 20 */
2678/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
2679
2680/*jshint node:true */
2681/*
2682
2683  The MIT License (MIT)
2684
2685  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2686
2687  Permission is hereby granted, free of charge, to any person
2688  obtaining a copy of this software and associated documentation files
2689  (the "Software"), to deal in the Software without restriction,
2690  including without limitation the rights to use, copy, modify, merge,
2691  publish, distribute, sublicense, and/or sell copies of the Software,
2692  and to permit persons to whom the Software is furnished to do so,
2693  subject to the following conditions:
2694
2695  The above copyright notice and this permission notice shall be
2696  included in all copies or substantial portions of the Software.
2697
2698  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2699  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2700  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2701  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2702  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2703  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2704  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2705  SOFTWARE.
2706*/
2707
2708
2709
2710var BaseOptions = (__webpack_require__(6).Options);
2711
2712function Options(options) {
2713  BaseOptions.call(this, options, 'html');
2714  if (this.templating.length === 1 && this.templating[0] === 'auto') {
2715    this.templating = ['django', 'erb', 'handlebars', 'php'];
2716  }
2717
2718  this.indent_inner_html = this._get_boolean('indent_inner_html');
2719  this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
2720  this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
2721
2722  this.indent_handlebars = this._get_boolean('indent_handlebars', true);
2723  this.wrap_attributes = this._get_selection('wrap_attributes',
2724    ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
2725  this.wrap_attributes_min_attrs = this._get_number('wrap_attributes_min_attrs', 2);
2726  this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
2727  this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
2728
2729  // Block vs inline elements
2730  // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
2731  // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
2732  // https://www.w3.org/TR/html5/dom.html#phrasing-content
2733  this.inline = this._get_array('inline', [
2734    'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
2735    'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
2736    'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
2737    'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
2738    'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
2739    'video', 'wbr', 'text',
2740    // obsolete inline tags
2741    'acronym', 'big', 'strike', 'tt'
2742  ]);
2743  this.inline_custom_elements = this._get_boolean('inline_custom_elements', true);
2744  this.void_elements = this._get_array('void_elements', [
2745    // HTLM void elements - aka self-closing tags - aka singletons
2746    // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
2747    'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
2748    'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
2749    // NOTE: Optional tags are too complex for a simple list
2750    // they are hard coded in _do_optional_end_element
2751
2752    // Doctype and xml elements
2753    '!doctype', '?xml',
2754
2755    // obsolete tags
2756    // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
2757    // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
2758    'basefont', 'isindex'
2759  ]);
2760  this.unformatted = this._get_array('unformatted', []);
2761  this.content_unformatted = this._get_array('content_unformatted', [
2762    'pre', 'textarea'
2763  ]);
2764  this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
2765  this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
2766
2767}
2768Options.prototype = new BaseOptions();
2769
2770
2771
2772module.exports.Options = Options;
2773
2774
2775/***/ }),
2776/* 21 */
2777/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
2778
2779/*jshint node:true */
2780/*
2781
2782  The MIT License (MIT)
2783
2784  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2785
2786  Permission is hereby granted, free of charge, to any person
2787  obtaining a copy of this software and associated documentation files
2788  (the "Software"), to deal in the Software without restriction,
2789  including without limitation the rights to use, copy, modify, merge,
2790  publish, distribute, sublicense, and/or sell copies of the Software,
2791  and to permit persons to whom the Software is furnished to do so,
2792  subject to the following conditions:
2793
2794  The above copyright notice and this permission notice shall be
2795  included in all copies or substantial portions of the Software.
2796
2797  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2798  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2799  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2800  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2801  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2802  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2803  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2804  SOFTWARE.
2805*/
2806
2807
2808
2809var BaseTokenizer = (__webpack_require__(9).Tokenizer);
2810var BASETOKEN = (__webpack_require__(9).TOKEN);
2811var Directives = (__webpack_require__(13).Directives);
2812var TemplatablePattern = (__webpack_require__(14).TemplatablePattern);
2813var Pattern = (__webpack_require__(12).Pattern);
2814
2815var TOKEN = {
2816  TAG_OPEN: 'TK_TAG_OPEN',
2817  TAG_CLOSE: 'TK_TAG_CLOSE',
2818  CONTROL_FLOW_OPEN: 'TK_CONTROL_FLOW_OPEN',
2819  CONTROL_FLOW_CLOSE: 'TK_CONTROL_FLOW_CLOSE',
2820  ATTRIBUTE: 'TK_ATTRIBUTE',
2821  EQUALS: 'TK_EQUALS',
2822  VALUE: 'TK_VALUE',
2823  COMMENT: 'TK_COMMENT',
2824  TEXT: 'TK_TEXT',
2825  UNKNOWN: 'TK_UNKNOWN',
2826  START: BASETOKEN.START,
2827  RAW: BASETOKEN.RAW,
2828  EOF: BASETOKEN.EOF
2829};
2830
2831var directives_core = new Directives(/<\!--/, /-->/);
2832
2833var Tokenizer = function(input_string, options) {
2834  BaseTokenizer.call(this, input_string, options);
2835  this._current_tag_name = '';
2836
2837  // Words end at whitespace or when a tag starts
2838  // if we are indenting handlebars, they are considered tags
2839  var templatable_reader = new TemplatablePattern(this._input).read_options(this._options);
2840  var pattern_reader = new Pattern(this._input);
2841
2842  this.__patterns = {
2843    word: templatable_reader.until(/[\n\r\t <]/),
2844    word_control_flow_close_excluded: templatable_reader.until(/[\n\r\t <}]/),
2845    single_quote: templatable_reader.until_after(/'/),
2846    double_quote: templatable_reader.until_after(/"/),
2847    attribute: templatable_reader.until(/[\n\r\t =>]|\/>/),
2848    element_name: templatable_reader.until(/[\n\r\t >\/]/),
2849
2850    angular_control_flow_start: pattern_reader.matching(/\@[a-zA-Z]+[^({]*[({]/),
2851    handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
2852    handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
2853    handlebars_open: pattern_reader.until(/[\n\r\t }]/),
2854    handlebars_raw_close: pattern_reader.until(/}}/),
2855    comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
2856    cdata: pattern_reader.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
2857    // https://en.wikipedia.org/wiki/Conditional_comment
2858    conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
2859    processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
2860  };
2861
2862  if (this._options.indent_handlebars) {
2863    this.__patterns.word = this.__patterns.word.exclude('handlebars');
2864    this.__patterns.word_control_flow_close_excluded = this.__patterns.word_control_flow_close_excluded.exclude('handlebars');
2865  }
2866
2867  this._unformatted_content_delimiter = null;
2868
2869  if (this._options.unformatted_content_delimiter) {
2870    var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
2871    this.__patterns.unformatted_content_delimiter =
2872      pattern_reader.matching(literal_regexp)
2873      .until_after(literal_regexp);
2874  }
2875};
2876Tokenizer.prototype = new BaseTokenizer();
2877
2878Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
2879  return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
2880};
2881
2882Tokenizer.prototype._is_opening = function(current_token) {
2883  return current_token.type === TOKEN.TAG_OPEN || current_token.type === TOKEN.CONTROL_FLOW_OPEN;
2884};
2885
2886Tokenizer.prototype._is_closing = function(current_token, open_token) {
2887  return (current_token.type === TOKEN.TAG_CLOSE &&
2888    (open_token && (
2889      ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
2890      (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')))
2891  ) || (current_token.type === TOKEN.CONTROL_FLOW_CLOSE &&
2892    (current_token.text === '}' && open_token.text.endsWith('{')));
2893};
2894
2895Tokenizer.prototype._reset = function() {
2896  this._current_tag_name = '';
2897};
2898
2899Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
2900  var token = null;
2901  this._readWhitespace();
2902  var c = this._input.peek();
2903
2904  if (c === null) {
2905    return this._create_token(TOKEN.EOF, '');
2906  }
2907
2908  token = token || this._read_open_handlebars(c, open_token);
2909  token = token || this._read_attribute(c, previous_token, open_token);
2910  token = token || this._read_close(c, open_token);
2911  token = token || this._read_script_and_style(c, previous_token);
2912  token = token || this._read_control_flows(c, open_token);
2913  token = token || this._read_raw_content(c, previous_token, open_token);
2914  token = token || this._read_content_word(c, open_token);
2915  token = token || this._read_comment_or_cdata(c);
2916  token = token || this._read_processing(c);
2917  token = token || this._read_open(c, open_token);
2918  token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
2919
2920  return token;
2921};
2922
2923Tokenizer.prototype._read_comment_or_cdata = function(c) { // jshint unused:false
2924  var token = null;
2925  var resulting_string = null;
2926  var directives = null;
2927
2928  if (c === '<') {
2929    var peek1 = this._input.peek(1);
2930    // We treat all comments as literals, even more than preformatted tags
2931    // we only look for the appropriate closing marker
2932    if (peek1 === '!') {
2933      resulting_string = this.__patterns.comment.read();
2934
2935      // only process directive on html comments
2936      if (resulting_string) {
2937        directives = directives_core.get_directives(resulting_string);
2938        if (directives && directives.ignore === 'start') {
2939          resulting_string += directives_core.readIgnored(this._input);
2940        }
2941      } else {
2942        resulting_string = this.__patterns.cdata.read();
2943      }
2944    }
2945
2946    if (resulting_string) {
2947      token = this._create_token(TOKEN.COMMENT, resulting_string);
2948      token.directives = directives;
2949    }
2950  }
2951
2952  return token;
2953};
2954
2955Tokenizer.prototype._read_processing = function(c) { // jshint unused:false
2956  var token = null;
2957  var resulting_string = null;
2958  var directives = null;
2959
2960  if (c === '<') {
2961    var peek1 = this._input.peek(1);
2962    if (peek1 === '!' || peek1 === '?') {
2963      resulting_string = this.__patterns.conditional_comment.read();
2964      resulting_string = resulting_string || this.__patterns.processing.read();
2965    }
2966
2967    if (resulting_string) {
2968      token = this._create_token(TOKEN.COMMENT, resulting_string);
2969      token.directives = directives;
2970    }
2971  }
2972
2973  return token;
2974};
2975
2976Tokenizer.prototype._read_open = function(c, open_token) {
2977  var resulting_string = null;
2978  var token = null;
2979  if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
2980    if (c === '<') {
2981
2982      resulting_string = this._input.next();
2983      if (this._input.peek() === '/') {
2984        resulting_string += this._input.next();
2985      }
2986      resulting_string += this.__patterns.element_name.read();
2987      token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
2988    }
2989  }
2990  return token;
2991};
2992
2993Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
2994  var resulting_string = null;
2995  var token = null;
2996  if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
2997    if ((this._options.templating.includes('angular') || this._options.indent_handlebars) && c === '{' && this._input.peek(1) === '{') {
2998      if (this._options.indent_handlebars && this._input.peek(2) === '!') {
2999        resulting_string = this.__patterns.handlebars_comment.read();
3000        resulting_string = resulting_string || this.__patterns.handlebars.read();
3001        token = this._create_token(TOKEN.COMMENT, resulting_string);
3002      } else {
3003        resulting_string = this.__patterns.handlebars_open.read();
3004        token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
3005      }
3006    }
3007  }
3008  return token;
3009};
3010
3011Tokenizer.prototype._read_control_flows = function(c, open_token) {
3012  var resulting_string = '';
3013  var token = null;
3014  // Only check for control flows if angular templating is set
3015  if (!this._options.templating.includes('angular')) {
3016    return token;
3017  }
3018
3019  if (c === '@') {
3020    resulting_string = this.__patterns.angular_control_flow_start.read();
3021    if (resulting_string === '') {
3022      return token;
3023    }
3024
3025    var opening_parentheses_count = resulting_string.endsWith('(') ? 1 : 0;
3026    var closing_parentheses_count = 0;
3027    // The opening brace of the control flow is where the number of opening and closing parentheses equal
3028    // e.g. @if({value: true} !== null) { 
3029    while (!(resulting_string.endsWith('{') && opening_parentheses_count === closing_parentheses_count)) {
3030      var next_char = this._input.next();
3031      if (next_char === null) {
3032        break;
3033      } else if (next_char === '(') {
3034        opening_parentheses_count++;
3035      } else if (next_char === ')') {
3036        closing_parentheses_count++;
3037      }
3038      resulting_string += next_char;
3039    }
3040    token = this._create_token(TOKEN.CONTROL_FLOW_OPEN, resulting_string);
3041  } else if (c === '}' && open_token && open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
3042    resulting_string = this._input.next();
3043    token = this._create_token(TOKEN.CONTROL_FLOW_CLOSE, resulting_string);
3044  }
3045  return token;
3046};
3047
3048
3049Tokenizer.prototype._read_close = function(c, open_token) {
3050  var resulting_string = null;
3051  var token = null;
3052  if (open_token && open_token.type === TOKEN.TAG_OPEN) {
3053    if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
3054      resulting_string = this._input.next();
3055      if (c === '/') { //  for close tag "/>"
3056        resulting_string += this._input.next();
3057      }
3058      token = this._create_token(TOKEN.TAG_CLOSE, resulting_string);
3059    } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
3060      this._input.next();
3061      this._input.next();
3062      token = this._create_token(TOKEN.TAG_CLOSE, '}}');
3063    }
3064  }
3065
3066  return token;
3067};
3068
3069Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) {
3070  var token = null;
3071  var resulting_string = '';
3072  if (open_token && open_token.text[0] === '<') {
3073
3074    if (c === '=') {
3075      token = this._create_token(TOKEN.EQUALS, this._input.next());
3076    } else if (c === '"' || c === "'") {
3077      var content = this._input.next();
3078      if (c === '"') {
3079        content += this.__patterns.double_quote.read();
3080      } else {
3081        content += this.__patterns.single_quote.read();
3082      }
3083      token = this._create_token(TOKEN.VALUE, content);
3084    } else {
3085      resulting_string = this.__patterns.attribute.read();
3086
3087      if (resulting_string) {
3088        if (previous_token.type === TOKEN.EQUALS) {
3089          token = this._create_token(TOKEN.VALUE, resulting_string);
3090        } else {
3091          token = this._create_token(TOKEN.ATTRIBUTE, resulting_string);
3092        }
3093      }
3094    }
3095  }
3096  return token;
3097};
3098
3099Tokenizer.prototype._is_content_unformatted = function(tag_name) {
3100  // void_elements have no content and so cannot have unformatted content
3101  // script and style tags should always be read as unformatted content
3102  // finally content_unformatted and unformatted element contents are unformatted
3103  return this._options.void_elements.indexOf(tag_name) === -1 &&
3104    (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
3105      this._options.unformatted.indexOf(tag_name) !== -1);
3106};
3107
3108Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
3109  var resulting_string = '';
3110  if (open_token && open_token.text[0] === '{') {
3111    resulting_string = this.__patterns.handlebars_raw_close.read();
3112  } else if (previous_token.type === TOKEN.TAG_CLOSE &&
3113    previous_token.opened.text[0] === '<' && previous_token.text[0] !== '/') {
3114    // ^^ empty tag has no content 
3115    var tag_name = previous_token.opened.text.substr(1).toLowerCase();
3116    if (this._is_content_unformatted(tag_name)) {
3117
3118      resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
3119    }
3120  }
3121
3122  if (resulting_string) {
3123    return this._create_token(TOKEN.TEXT, resulting_string);
3124  }
3125
3126  return null;
3127};
3128
3129Tokenizer.prototype._read_script_and_style = function(c, previous_token) { // jshint unused:false 
3130  if (previous_token.type === TOKEN.TAG_CLOSE && previous_token.opened.text[0] === '<' && previous_token.text[0] !== '/') {
3131    var tag_name = previous_token.opened.text.substr(1).toLowerCase();
3132    if (tag_name === 'script' || tag_name === 'style') {
3133      // Script and style tags are allowed to have comments wrapping their content
3134      // or just have regular content.
3135      var token = this._read_comment_or_cdata(c);
3136      if (token) {
3137        token.type = TOKEN.TEXT;
3138        return token;
3139      }
3140      var resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
3141      if (resulting_string) {
3142        return this._create_token(TOKEN.TEXT, resulting_string);
3143      }
3144    }
3145  }
3146  return null;
3147};
3148
3149Tokenizer.prototype._read_content_word = function(c, open_token) {
3150  var resulting_string = '';
3151  if (this._options.unformatted_content_delimiter) {
3152    if (c === this._options.unformatted_content_delimiter[0]) {
3153      resulting_string = this.__patterns.unformatted_content_delimiter.read();
3154    }
3155  }
3156
3157  if (!resulting_string) {
3158    resulting_string = (open_token && open_token.type === TOKEN.CONTROL_FLOW_OPEN) ? this.__patterns.word_control_flow_close_excluded.read() : this.__patterns.word.read();
3159  }
3160  if (resulting_string) {
3161    return this._create_token(TOKEN.TEXT, resulting_string);
3162  }
3163  return null;
3164};
3165
3166module.exports.Tokenizer = Tokenizer;
3167module.exports.TOKEN = TOKEN;
3168
3169
3170/***/ })
3171/******/ 	]);
3172/************************************************************************/
3173/******/ 	// The module cache
3174/******/ 	var __webpack_module_cache__ = {};
3175/******/ 	
3176/******/ 	// The require function
3177/******/ 	function __webpack_require__(moduleId) {
3178/******/ 		// Check if module is in cache
3179/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
3180/******/ 		if (cachedModule !== undefined) {
3181/******/ 			return cachedModule.exports;
3182/******/ 		}
3183/******/ 		// Create a new module (and put it into the cache)
3184/******/ 		var module = __webpack_module_cache__[moduleId] = {
3185/******/ 			// no module.id needed
3186/******/ 			// no module.loaded needed
3187/******/ 			exports: {}
3188/******/ 		};
3189/******/ 	
3190/******/ 		// Execute the module function
3191/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
3192/******/ 	
3193/******/ 		// Return the exports of the module
3194/******/ 		return module.exports;
3195/******/ 	}
3196/******/ 	
3197/************************************************************************/
3198/******/ 	
3199/******/ 	// startup
3200/******/ 	// Load entry module and return exports
3201/******/ 	// This entry module is referenced by other modules so it can't be inlined
3202/******/ 	var __webpack_exports__ = __webpack_require__(18);
3203/******/ 	legacy_beautify_html = __webpack_exports__;
3204/******/ 	
3205/******/ })()
3206;
3207var style_html = legacy_beautify_html;
3208/* Footer */
3209if (typeof define === "function" && define.amd) {
3210    // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
3211    define(["require", "./beautify", "./beautify-css"], function(requireamd) {
3212        var js_beautify = requireamd("./beautify");
3213        var css_beautify = requireamd("./beautify-css");
3214
3215        return {
3216            html_beautify: function(html_source, options) {
3217                return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
3218            }
3219        };
3220    });
3221} else if (typeof exports !== "undefined") {
3222    // Add support for CommonJS. Just put this file somewhere on your require.paths
3223    // and you will be able to `var html_beautify = require("beautify").html_beautify`.
3224    var js_beautify = require('./beautify.js');
3225    var css_beautify = require('./beautify-css.js');
3226
3227    exports.html_beautify = function(html_source, options) {
3228        return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
3229    };
3230} else if (typeof window !== "undefined") {
3231    // If we're running a web page and don't have either of the above, add our one global
3232    window.html_beautify = function(html_source, options) {
3233        return style_html(html_source, options, window.js_beautify, window.css_beautify);
3234    };
3235} else if (typeof global !== "undefined") {
3236    // If we don't even have window, try global.
3237    global.html_beautify = function(html_source, options) {
3238        return style_html(html_source, options, global.js_beautify, global.css_beautify);
3239    };
3240}
3241
3242}());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.