js-beautify 1.9.0-beta2 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,7 +159,7 @@ var legacy_beautify_html =
159
159
  /******/
160
160
  /******/
161
161
  /******/ // Load entry module and return exports
162
- /******/ return __webpack_require__(__webpack_require__.s = 15);
162
+ /******/ return __webpack_require__(__webpack_require__.s = 18);
163
163
  /******/ })
164
164
  /************************************************************************/
165
165
  /******/ ([
@@ -292,14 +292,11 @@ OutputLine.prototype.last = function() {
292
292
 
293
293
  OutputLine.prototype.push = function(item) {
294
294
  this.__items.push(item);
295
- this.__character_count += item.length;
296
- };
297
-
298
- OutputLine.prototype.push_raw = function(item) {
299
- this.push(item);
300
295
  var last_newline_index = item.lastIndexOf('\n');
301
296
  if (last_newline_index !== -1) {
302
297
  this.__character_count = item.length - last_newline_index;
298
+ } else {
299
+ this.__character_count += item.length;
303
300
  }
304
301
  };
305
302
 
@@ -512,7 +509,7 @@ Output.prototype.add_raw_token = function(token) {
512
509
  }
513
510
  this.current_line.set_indent(-1);
514
511
  this.current_line.push(token.whitespace_before);
515
- this.current_line.push_raw(token.text);
512
+ this.current_line.push(token.text);
516
513
  this.space_before_token = false;
517
514
  this.non_breaking_space = false;
518
515
  this.previous_token_wrapped = false;
@@ -881,6 +878,8 @@ module.exports.mergeOpts = _mergeOpts;
881
878
 
882
879
 
883
880
 
881
+ var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
882
+
884
883
  function InputScanner(input_string) {
885
884
  this.__input = input_string || '';
886
885
  this.__input_length = this.__input.length;
@@ -920,14 +919,32 @@ InputScanner.prototype.peek = function(index) {
920
919
  return val;
921
920
  };
922
921
 
922
+ // This is a JavaScript only helper function (not in python)
923
+ // Javascript doesn't have a match method
924
+ // and not all implementation support "sticky" flag.
925
+ // If they do not support sticky then both this.match() and this.test() method
926
+ // must get the match and check the index of the match.
927
+ // If sticky is supported and set, this method will use it.
928
+ // Otherwise it will check that global is set, and fall back to the slower method.
929
+ InputScanner.prototype.__match = function(pattern, index) {
930
+ pattern.lastIndex = index;
931
+ var pattern_match = pattern.exec(this.__input);
932
+
933
+ if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
934
+ if (pattern_match.index !== index) {
935
+ pattern_match = null;
936
+ }
937
+ }
938
+
939
+ return pattern_match;
940
+ };
941
+
923
942
  InputScanner.prototype.test = function(pattern, index) {
924
943
  index = index || 0;
925
944
  index += this.__position;
926
- pattern.lastIndex = index;
927
945
 
928
946
  if (index >= 0 && index < this.__input_length) {
929
- var pattern_match = pattern.exec(this.__input);
930
- return pattern_match && pattern_match.index === index;
947
+ return !!this.__match(pattern, index);
931
948
  } else {
932
949
  return false;
933
950
  }
@@ -941,9 +958,8 @@ InputScanner.prototype.testChar = function(pattern, index) {
941
958
  };
942
959
 
943
960
  InputScanner.prototype.match = function(pattern) {
944
- pattern.lastIndex = this.__position;
945
- var pattern_match = pattern.exec(this.__input);
946
- if (pattern_match && pattern_match.index === this.__position) {
961
+ var pattern_match = this.__match(pattern, this.__position);
962
+ if (pattern_match) {
947
963
  this.__position += pattern_match[0].length;
948
964
  } else {
949
965
  pattern_match = null;
@@ -951,28 +967,30 @@ InputScanner.prototype.match = function(pattern) {
951
967
  return pattern_match;
952
968
  };
953
969
 
954
- InputScanner.prototype.read = function(pattern, untilAfterPattern) {
970
+ InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
955
971
  var val = '';
956
- var match = this.match(pattern);
957
- if (match) {
958
- val = match[0];
959
- if (untilAfterPattern) {
960
- val += this.readUntilAfter(untilAfterPattern);
972
+ var match;
973
+ if (starting_pattern) {
974
+ match = this.match(starting_pattern);
975
+ if (match) {
976
+ val += match[0];
961
977
  }
962
978
  }
979
+ if (until_pattern && (match || !starting_pattern)) {
980
+ val += this.readUntil(until_pattern, until_after);
981
+ }
963
982
  return val;
964
983
  };
965
984
 
966
- InputScanner.prototype.readUntil = function(pattern, include_match) {
985
+ InputScanner.prototype.readUntil = function(pattern, until_after) {
967
986
  var val = '';
968
987
  var match_index = this.__position;
969
988
  pattern.lastIndex = this.__position;
970
989
  var pattern_match = pattern.exec(this.__input);
971
990
  if (pattern_match) {
972
- if (include_match) {
973
- match_index = pattern_match.index + pattern_match[0].length;
974
- } else {
975
- match_index = pattern_match.index;
991
+ match_index = pattern_match.index;
992
+ if (until_after) {
993
+ match_index += pattern_match[0].length;
976
994
  }
977
995
  } else {
978
996
  match_index = this.__input_length;
@@ -987,6 +1005,26 @@ InputScanner.prototype.readUntilAfter = function(pattern) {
987
1005
  return this.readUntil(pattern, true);
988
1006
  };
989
1007
 
1008
+ InputScanner.prototype.get_regexp = function(pattern, match_from) {
1009
+ var result = null;
1010
+ var flags = 'g';
1011
+ if (match_from && regexp_has_sticky) {
1012
+ flags = 'y';
1013
+ }
1014
+ // strings are converted to regexp
1015
+ if (typeof pattern === "string" && pattern !== '') {
1016
+ // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
1017
+ result = new RegExp(pattern, flags);
1018
+ } else if (pattern) {
1019
+ result = new RegExp(pattern.source, flags);
1020
+ }
1021
+ return result;
1022
+ };
1023
+
1024
+ InputScanner.prototype.get_literal_regexp = function(literal_string) {
1025
+ return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
1026
+ };
1027
+
990
1028
  /* css beautifier legacy helpers */
991
1029
  InputScanner.prototype.peekUntilAfter = function(pattern) {
992
1030
  var start = this.__position;
@@ -1001,7 +1039,6 @@ InputScanner.prototype.lookBack = function(testVal) {
1001
1039
  .toLowerCase() === testVal;
1002
1040
  };
1003
1041
 
1004
-
1005
1042
  module.exports.InputScanner = InputScanner;
1006
1043
 
1007
1044
 
@@ -1043,6 +1080,7 @@ module.exports.InputScanner = InputScanner;
1043
1080
  var InputScanner = __webpack_require__(8).InputScanner;
1044
1081
  var Token = __webpack_require__(3).Token;
1045
1082
  var TokenStream = __webpack_require__(10).TokenStream;
1083
+ var WhitespacePattern = __webpack_require__(11).WhitespacePattern;
1046
1084
 
1047
1085
  var TOKEN = {
1048
1086
  START: 'TK_START',
@@ -1054,11 +1092,9 @@ var Tokenizer = function(input_string, options) {
1054
1092
  this._input = new InputScanner(input_string);
1055
1093
  this._options = options || {};
1056
1094
  this.__tokens = null;
1057
- this.__newline_count = 0;
1058
- this.__whitespace_before_token = '';
1059
1095
 
1060
- this._whitespace_pattern = /[\n\r\t ]+/g;
1061
- this._newline_pattern = /([^\n\r]*)(\r\n|[\n\r])?/g;
1096
+ this._patterns = {};
1097
+ this._patterns.whitespace = new WhitespacePattern(this._input);
1062
1098
  };
1063
1099
 
1064
1100
  Tokenizer.prototype.tokenize = function() {
@@ -1137,28 +1173,14 @@ Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshin
1137
1173
  };
1138
1174
 
1139
1175
  Tokenizer.prototype._create_token = function(type, text) {
1140
- var token = new Token(type, text, this.__newline_count, this.__whitespace_before_token);
1141
- this.__newline_count = 0;
1142
- this.__whitespace_before_token = '';
1176
+ var token = new Token(type, text,
1177
+ this._patterns.whitespace.newline_count,
1178
+ this._patterns.whitespace.whitespace_before_token);
1143
1179
  return token;
1144
1180
  };
1145
1181
 
1146
1182
  Tokenizer.prototype._readWhitespace = function() {
1147
- if (!this._input.testChar(this._whitespace_pattern)) {
1148
- return;
1149
- }
1150
- var resulting_string = this._input.read(this._whitespace_pattern);
1151
- if (resulting_string === ' ') {
1152
- this.__whitespace_before_token = resulting_string;
1153
- } else if (resulting_string !== '') {
1154
- this._newline_pattern.lastIndex = 0;
1155
- var nextMatch = this._newline_pattern.exec(resulting_string);
1156
- while (nextMatch[2]) {
1157
- this.__newline_count += 1;
1158
- nextMatch = this._newline_pattern.exec(resulting_string);
1159
- }
1160
- this.__whitespace_before_token = nextMatch[1];
1161
- }
1183
+ return this._patterns.whitespace.read();
1162
1184
  };
1163
1185
 
1164
1186
 
@@ -1287,13 +1309,226 @@ module.exports.TokenStream = TokenStream;
1287
1309
 
1288
1310
 
1289
1311
 
1312
+ var Pattern = __webpack_require__(12).Pattern;
1313
+
1314
+ function WhitespacePattern(input_scanner, parent) {
1315
+ Pattern.call(this, input_scanner, parent);
1316
+ if (parent) {
1317
+ this._line_regexp = this._input.get_regexp(parent._line_regexp);
1318
+ } else {
1319
+ this.__set_whitespace_patterns('', '');
1320
+ }
1321
+
1322
+ this.newline_count = 0;
1323
+ this.whitespace_before_token = '';
1324
+ }
1325
+ WhitespacePattern.prototype = new Pattern();
1326
+
1327
+ WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
1328
+ whitespace_chars += '\\t ';
1329
+ newline_chars += '\\n\\r';
1330
+
1331
+ this._match_pattern = this._input.get_regexp(
1332
+ '[' + whitespace_chars + newline_chars + ']+', true);
1333
+ this._newline_regexp = this._input.get_regexp(
1334
+ '\\r\\n|[' + newline_chars + ']');
1335
+ };
1336
+
1337
+ WhitespacePattern.prototype.read = function() {
1338
+ this.newline_count = 0;
1339
+ this.whitespace_before_token = '';
1340
+
1341
+ var resulting_string = this._input.read(this._match_pattern);
1342
+ if (resulting_string === ' ') {
1343
+ this.whitespace_before_token = ' ';
1344
+ } else if (resulting_string) {
1345
+ var matches = this.__split(this._newline_regexp, resulting_string);
1346
+ this.newline_count = matches.length - 1;
1347
+ this.whitespace_before_token = matches[this.newline_count];
1348
+ }
1349
+
1350
+ return resulting_string;
1351
+ };
1352
+
1353
+ WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
1354
+ var result = this._create();
1355
+ result.__set_whitespace_patterns(whitespace_chars, newline_chars);
1356
+ result._update();
1357
+ return result;
1358
+ };
1359
+
1360
+ WhitespacePattern.prototype._create = function() {
1361
+ return new WhitespacePattern(this._input, this);
1362
+ };
1363
+
1364
+ WhitespacePattern.prototype.__split = function(regexp, input_string) {
1365
+ regexp.lastIndex = 0;
1366
+ var start_index = 0;
1367
+ var result = [];
1368
+ var next_match = regexp.exec(input_string);
1369
+ while (next_match) {
1370
+ result.push(input_string.substring(start_index, next_match.index));
1371
+ start_index = next_match.index + next_match[0].length;
1372
+ next_match = regexp.exec(input_string);
1373
+ }
1374
+
1375
+ if (start_index < input_string.length) {
1376
+ result.push(input_string.substring(start_index, input_string.length));
1377
+ } else {
1378
+ result.push('');
1379
+ }
1380
+
1381
+ return result;
1382
+ };
1383
+
1384
+
1385
+
1386
+ module.exports.WhitespacePattern = WhitespacePattern;
1387
+
1388
+
1389
+ /***/ }),
1390
+ /* 12 */
1391
+ /***/ (function(module, exports, __webpack_require__) {
1392
+
1393
+ "use strict";
1394
+ /*jshint node:true */
1395
+ /*
1396
+
1397
+ The MIT License (MIT)
1398
+
1399
+ Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1400
+
1401
+ Permission is hereby granted, free of charge, to any person
1402
+ obtaining a copy of this software and associated documentation files
1403
+ (the "Software"), to deal in the Software without restriction,
1404
+ including without limitation the rights to use, copy, modify, merge,
1405
+ publish, distribute, sublicense, and/or sell copies of the Software,
1406
+ and to permit persons to whom the Software is furnished to do so,
1407
+ subject to the following conditions:
1408
+
1409
+ The above copyright notice and this permission notice shall be
1410
+ included in all copies or substantial portions of the Software.
1411
+
1412
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1413
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1414
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1415
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1416
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1417
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1418
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1419
+ SOFTWARE.
1420
+ */
1421
+
1422
+
1423
+
1424
+ function Pattern(input_scanner, parent) {
1425
+ this._input = input_scanner;
1426
+ this._starting_pattern = null;
1427
+ this._match_pattern = null;
1428
+ this._until_pattern = null;
1429
+ this._until_after = false;
1430
+
1431
+ if (parent) {
1432
+ this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
1433
+ this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
1434
+ this._until_pattern = this._input.get_regexp(parent._until_pattern);
1435
+ this._until_after = parent._until_after;
1436
+ }
1437
+ }
1438
+
1439
+ Pattern.prototype.read = function() {
1440
+ var result = this._input.read(this._starting_pattern);
1441
+ if (!this._starting_pattern || result) {
1442
+ result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
1443
+ }
1444
+ return result;
1445
+ };
1446
+
1447
+ Pattern.prototype.read_match = function() {
1448
+ return this._input.match(this._match_pattern);
1449
+ };
1450
+
1451
+ Pattern.prototype.until_after = function(pattern) {
1452
+ var result = this._create();
1453
+ result._until_after = true;
1454
+ result._until_pattern = this._input.get_regexp(pattern);
1455
+ result._update();
1456
+ return result;
1457
+ };
1458
+
1459
+ Pattern.prototype.until = function(pattern) {
1460
+ var result = this._create();
1461
+ result._until_after = false;
1462
+ result._until_pattern = this._input.get_regexp(pattern);
1463
+ result._update();
1464
+ return result;
1465
+ };
1466
+
1467
+ Pattern.prototype.starting_with = function(pattern) {
1468
+ var result = this._create();
1469
+ result._starting_pattern = this._input.get_regexp(pattern, true);
1470
+ result._update();
1471
+ return result;
1472
+ };
1473
+
1474
+ Pattern.prototype.matching = function(pattern) {
1475
+ var result = this._create();
1476
+ result._match_pattern = this._input.get_regexp(pattern, true);
1477
+ result._update();
1478
+ return result;
1479
+ };
1480
+
1481
+ Pattern.prototype._create = function() {
1482
+ return new Pattern(this._input, this);
1483
+ };
1484
+
1485
+ Pattern.prototype._update = function() {};
1486
+
1487
+ module.exports.Pattern = Pattern;
1488
+
1489
+
1490
+ /***/ }),
1491
+ /* 13 */
1492
+ /***/ (function(module, exports, __webpack_require__) {
1493
+
1494
+ "use strict";
1495
+ /*jshint node:true */
1496
+ /*
1497
+
1498
+ The MIT License (MIT)
1499
+
1500
+ Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1501
+
1502
+ Permission is hereby granted, free of charge, to any person
1503
+ obtaining a copy of this software and associated documentation files
1504
+ (the "Software"), to deal in the Software without restriction,
1505
+ including without limitation the rights to use, copy, modify, merge,
1506
+ publish, distribute, sublicense, and/or sell copies of the Software,
1507
+ and to permit persons to whom the Software is furnished to do so,
1508
+ subject to the following conditions:
1509
+
1510
+ The above copyright notice and this permission notice shall be
1511
+ included in all copies or substantial portions of the Software.
1512
+
1513
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1514
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1515
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1516
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1517
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1518
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1519
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1520
+ SOFTWARE.
1521
+ */
1522
+
1523
+
1524
+
1290
1525
  function Directives(start_block_pattern, end_block_pattern) {
1291
1526
  start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
1292
1527
  end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
1293
1528
  this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
1294
1529
  this.__directive_pattern = / (\w+)[:](\w+)/g;
1295
1530
 
1296
- this.__directives_end_ignore_pattern = new RegExp('(?:[\\s\\S]*?)((?:' + start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern + ')|$)', 'g');
1531
+ this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
1297
1532
  }
1298
1533
 
1299
1534
  Directives.prototype.get_directives = function(text) {
@@ -1314,7 +1549,7 @@ Directives.prototype.get_directives = function(text) {
1314
1549
  };
1315
1550
 
1316
1551
  Directives.prototype.readIgnored = function(input) {
1317
- return input.read(this.__directives_end_ignore_pattern);
1552
+ return input.readUntilAfter(this.__directives_end_ignore_pattern);
1318
1553
  };
1319
1554
 
1320
1555
 
@@ -1322,10 +1557,7 @@ module.exports.Directives = Directives;
1322
1557
 
1323
1558
 
1324
1559
  /***/ }),
1325
- /* 12 */,
1326
- /* 13 */,
1327
- /* 14 */,
1328
- /* 15 */
1560
+ /* 14 */
1329
1561
  /***/ (function(module, exports, __webpack_require__) {
1330
1562
 
1331
1563
  "use strict";
@@ -1359,8 +1591,197 @@ module.exports.Directives = Directives;
1359
1591
 
1360
1592
 
1361
1593
 
1362
- var Beautifier = __webpack_require__(16).Beautifier,
1363
- Options = __webpack_require__(17).Options;
1594
+ var Pattern = __webpack_require__(12).Pattern;
1595
+
1596
+
1597
+ var template_names = {
1598
+ django: false,
1599
+ erb: false,
1600
+ handlebars: false,
1601
+ php: false
1602
+ };
1603
+
1604
+ // This lets templates appear anywhere we would do a readUntil
1605
+ // The cost is higher but it is pay to play.
1606
+ function TemplatablePattern(input_scanner, parent) {
1607
+ Pattern.call(this, input_scanner, parent);
1608
+ this.__template_pattern = null;
1609
+ this._disabled = Object.assign({}, template_names);
1610
+ this._excluded = Object.assign({}, template_names);
1611
+
1612
+ if (parent) {
1613
+ this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
1614
+ this._excluded = Object.assign(this._excluded, parent._excluded);
1615
+ this._disabled = Object.assign(this._disabled, parent._disabled);
1616
+ }
1617
+ var pattern = new Pattern(input_scanner);
1618
+ this.__patterns = {
1619
+ handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
1620
+ handlebars: pattern.starting_with(/{{/).until_after(/}}/),
1621
+ php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
1622
+ erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
1623
+ // django coflicts with handlebars a bit.
1624
+ django: pattern.starting_with(/{%/).until_after(/%}/),
1625
+ django_value: pattern.starting_with(/{{/).until_after(/}}/),
1626
+ django_comment: pattern.starting_with(/{#/).until_after(/#}/)
1627
+ };
1628
+ }
1629
+ TemplatablePattern.prototype = new Pattern();
1630
+
1631
+ TemplatablePattern.prototype._create = function() {
1632
+ return new TemplatablePattern(this._input, this);
1633
+ };
1634
+
1635
+ TemplatablePattern.prototype._update = function() {
1636
+ this.__set_templated_pattern();
1637
+ };
1638
+
1639
+ TemplatablePattern.prototype.disable = function(language) {
1640
+ var result = this._create();
1641
+ result._disabled[language] = true;
1642
+ result._update();
1643
+ return result;
1644
+ };
1645
+
1646
+ TemplatablePattern.prototype.exclude = function(language) {
1647
+ var result = this._create();
1648
+ result._excluded[language] = true;
1649
+ result._update();
1650
+ return result;
1651
+ };
1652
+
1653
+ TemplatablePattern.prototype.read = function() {
1654
+ var result = '';
1655
+ if (this._match_pattern) {
1656
+ result = this._input.read(this._starting_pattern);
1657
+ } else {
1658
+ result = this._input.read(this._starting_pattern, this.__template_pattern);
1659
+ }
1660
+ var next = this._read_template();
1661
+ while (next) {
1662
+ if (this._match_pattern) {
1663
+ next += this._input.read(this._match_pattern);
1664
+ } else {
1665
+ next += this._input.readUntil(this.__template_pattern);
1666
+ }
1667
+ result += next;
1668
+ next = this._read_template();
1669
+ }
1670
+
1671
+ if (this._until_after) {
1672
+ result += this._input.readUntilAfter(this._until_pattern);
1673
+ }
1674
+ return result;
1675
+ };
1676
+
1677
+ TemplatablePattern.prototype.__set_templated_pattern = function() {
1678
+ var items = [];
1679
+
1680
+ if (!this._disabled.php) {
1681
+ items.push(this.__patterns.php._starting_pattern.source);
1682
+ }
1683
+ if (!this._disabled.handlebars) {
1684
+ items.push(this.__patterns.handlebars._starting_pattern.source);
1685
+ }
1686
+ if (!this._disabled.erb) {
1687
+ items.push(this.__patterns.erb._starting_pattern.source);
1688
+ }
1689
+ if (!this._disabled.django) {
1690
+ items.push(this.__patterns.django._starting_pattern.source);
1691
+ items.push(this.__patterns.django_value._starting_pattern.source);
1692
+ items.push(this.__patterns.django_comment._starting_pattern.source);
1693
+ }
1694
+
1695
+ if (this._until_pattern) {
1696
+ items.push(this._until_pattern.source);
1697
+ }
1698
+ this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
1699
+ };
1700
+
1701
+ TemplatablePattern.prototype._read_template = function() {
1702
+ var resulting_string = '';
1703
+ var c = this._input.peek();
1704
+ if (c === '<') {
1705
+ var peek1 = this._input.peek(1);
1706
+ //if we're in a comment, do something special
1707
+ // We treat all comments as literals, even more than preformatted tags
1708
+ // we just look for the appropriate close tag
1709
+ if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
1710
+ resulting_string = resulting_string ||
1711
+ this.__patterns.php.read();
1712
+ }
1713
+ if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
1714
+ resulting_string = resulting_string ||
1715
+ this.__patterns.erb.read();
1716
+ }
1717
+ } else if (c === '{') {
1718
+ if (!this._disabled.handlebars && !this._excluded.handlebars) {
1719
+ resulting_string = resulting_string ||
1720
+ this.__patterns.handlebars_comment.read();
1721
+ resulting_string = resulting_string ||
1722
+ this.__patterns.handlebars.read();
1723
+ }
1724
+ if (!this._disabled.django) {
1725
+ // django coflicts with handlebars a bit.
1726
+ if (!this._excluded.django && !this._excluded.handlebars) {
1727
+ resulting_string = resulting_string ||
1728
+ this.__patterns.django_value.read();
1729
+ }
1730
+ if (!this._excluded.django) {
1731
+ resulting_string = resulting_string ||
1732
+ this.__patterns.django_comment.read();
1733
+ resulting_string = resulting_string ||
1734
+ this.__patterns.django.read();
1735
+ }
1736
+ }
1737
+ }
1738
+ return resulting_string;
1739
+ };
1740
+
1741
+
1742
+ module.exports.TemplatablePattern = TemplatablePattern;
1743
+
1744
+
1745
+ /***/ }),
1746
+ /* 15 */,
1747
+ /* 16 */,
1748
+ /* 17 */,
1749
+ /* 18 */
1750
+ /***/ (function(module, exports, __webpack_require__) {
1751
+
1752
+ "use strict";
1753
+ /*jshint node:true */
1754
+ /*
1755
+
1756
+ The MIT License (MIT)
1757
+
1758
+ Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1759
+
1760
+ Permission is hereby granted, free of charge, to any person
1761
+ obtaining a copy of this software and associated documentation files
1762
+ (the "Software"), to deal in the Software without restriction,
1763
+ including without limitation the rights to use, copy, modify, merge,
1764
+ publish, distribute, sublicense, and/or sell copies of the Software,
1765
+ and to permit persons to whom the Software is furnished to do so,
1766
+ subject to the following conditions:
1767
+
1768
+ The above copyright notice and this permission notice shall be
1769
+ included in all copies or substantial portions of the Software.
1770
+
1771
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1772
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1773
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1774
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1775
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1776
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1777
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1778
+ SOFTWARE.
1779
+ */
1780
+
1781
+
1782
+
1783
+ var Beautifier = __webpack_require__(19).Beautifier,
1784
+ Options = __webpack_require__(20).Options;
1364
1785
 
1365
1786
  function style_html(html_source, options, js_beautify, css_beautify) {
1366
1787
  var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify);
@@ -1374,7 +1795,7 @@ module.exports.defaultOptions = function() {
1374
1795
 
1375
1796
 
1376
1797
  /***/ }),
1377
- /* 16 */
1798
+ /* 19 */
1378
1799
  /***/ (function(module, exports, __webpack_require__) {
1379
1800
 
1380
1801
  "use strict";
@@ -1408,10 +1829,10 @@ module.exports.defaultOptions = function() {
1408
1829
 
1409
1830
 
1410
1831
 
1411
- var Options = __webpack_require__(17).Options;
1832
+ var Options = __webpack_require__(20).Options;
1412
1833
  var Output = __webpack_require__(2).Output;
1413
- var Tokenizer = __webpack_require__(18).Tokenizer;
1414
- var TOKEN = __webpack_require__(18).TOKEN;
1834
+ var Tokenizer = __webpack_require__(21).Tokenizer;
1835
+ var TOKEN = __webpack_require__(21).TOKEN;
1415
1836
 
1416
1837
  var lineBreak = /\r\n|[\r\n]/;
1417
1838
  var allLineBreaks = /\r\n|[\r\n]/g;
@@ -1941,7 +2362,7 @@ var TagOpenParserToken = function(parent, raw_token) {
1941
2362
  tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
1942
2363
  this.tag_check = tag_check_match ? tag_check_match[1] : '';
1943
2364
  } else {
1944
- tag_check_match = raw_token.text.match(/^{{\#?([^\s}]+)/);
2365
+ tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
1945
2366
  this.tag_check = tag_check_match ? tag_check_match[1] : '';
1946
2367
  }
1947
2368
  this.tag_check = this.tag_check.toLowerCase();
@@ -1987,7 +2408,15 @@ Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_tok
1987
2408
  } else { // it's a start-tag
1988
2409
  // check if this tag is starting an element that has optional end element
1989
2410
  // and do an ending needed
1990
- this._do_optional_end_element(parser_token);
2411
+ if (this._do_optional_end_element(parser_token)) {
2412
+ if (!parser_token.is_inline_element) {
2413
+ if (parser_token.parent) {
2414
+ parser_token.parent.multiline_content = true;
2415
+ }
2416
+ printer.print_newline(false);
2417
+ }
2418
+
2419
+ }
1991
2420
 
1992
2421
  this._tag_stack.record_tag(parser_token); //push it on the tag stack
1993
2422
 
@@ -2066,6 +2495,7 @@ Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_tok
2066
2495
  //var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
2067
2496
 
2068
2497
  Beautifier.prototype._do_optional_end_element = function(parser_token) {
2498
+ var result = null;
2069
2499
  // NOTE: cases of "if there is no more content in the parent element"
2070
2500
  // are handled automatically by the beautifier.
2071
2501
  // It assumes parent or ancestor close tag closes all children.
@@ -2075,52 +2505,52 @@ Beautifier.prototype._do_optional_end_element = function(parser_token) {
2075
2505
 
2076
2506
  } else if (parser_token.tag_name === 'body') {
2077
2507
  // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
2078
- this._tag_stack.try_pop('head');
2508
+ result = result || this._tag_stack.try_pop('head');
2079
2509
 
2080
2510
  //} else if (parser_token.tag_name === 'body') {
2081
2511
  // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
2082
2512
 
2083
2513
  } else if (parser_token.tag_name === 'li') {
2084
2514
  // 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.
2085
- this._tag_stack.try_pop('li', ['ol', 'ul']);
2515
+ result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
2086
2516
 
2087
2517
  } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
2088
2518
  // 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.
2089
2519
  // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
2090
- this._tag_stack.try_pop('dt', ['dl']);
2091
- this._tag_stack.try_pop('dd', ['dl']);
2520
+ result = result || this._tag_stack.try_pop('dt', ['dl']);
2521
+ result = result || this._tag_stack.try_pop('dd', ['dl']);
2092
2522
 
2093
2523
  //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
2094
2524
  //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
2095
2525
  //A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
2096
- //this._tag_stack.try_pop('p', ['body']);
2526
+ //result = result || this._tag_stack.try_pop('p', ['body']);
2097
2527
 
2098
2528
  } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
2099
2529
  // 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.
2100
2530
  // 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.
2101
- this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
2102
- this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
2531
+ result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
2532
+ result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
2103
2533
 
2104
2534
  } else if (parser_token.tag_name === 'optgroup') {
2105
2535
  // 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.
2106
2536
  // 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.
2107
- this._tag_stack.try_pop('optgroup', ['select']);
2108
- //this._tag_stack.try_pop('option', ['select']);
2537
+ result = result || this._tag_stack.try_pop('optgroup', ['select']);
2538
+ //result = result || this._tag_stack.try_pop('option', ['select']);
2109
2539
 
2110
2540
  } else if (parser_token.tag_name === 'option') {
2111
2541
  // 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.
2112
- this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
2542
+ result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
2113
2543
 
2114
2544
  } else if (parser_token.tag_name === 'colgroup') {
2115
2545
  // 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.
2116
2546
  // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2117
- this._tag_stack.try_pop('caption', ['table']);
2547
+ result = result || this._tag_stack.try_pop('caption', ['table']);
2118
2548
 
2119
2549
  } else if (parser_token.tag_name === 'thead') {
2120
2550
  // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
2121
2551
  // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2122
- this._tag_stack.try_pop('caption', ['table']);
2123
- this._tag_stack.try_pop('colgroup', ['table']);
2552
+ result = result || this._tag_stack.try_pop('caption', ['table']);
2553
+ result = result || this._tag_stack.try_pop('colgroup', ['table']);
2124
2554
 
2125
2555
  //} else if (parser_token.tag_name === 'caption') {
2126
2556
  // 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.
@@ -2130,10 +2560,10 @@ Beautifier.prototype._do_optional_end_element = function(parser_token) {
2130
2560
  // 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.
2131
2561
  // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
2132
2562
  // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2133
- this._tag_stack.try_pop('caption', ['table']);
2134
- this._tag_stack.try_pop('colgroup', ['table']);
2135
- this._tag_stack.try_pop('thead', ['table']);
2136
- this._tag_stack.try_pop('tbody', ['table']);
2563
+ result = result || this._tag_stack.try_pop('caption', ['table']);
2564
+ result = result || this._tag_stack.try_pop('colgroup', ['table']);
2565
+ result = result || this._tag_stack.try_pop('thead', ['table']);
2566
+ result = result || this._tag_stack.try_pop('tbody', ['table']);
2137
2567
 
2138
2568
  //} else if (parser_token.tag_name === 'tfoot') {
2139
2569
  // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
@@ -2142,15 +2572,15 @@ Beautifier.prototype._do_optional_end_element = function(parser_token) {
2142
2572
  // 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.
2143
2573
  // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
2144
2574
  // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
2145
- this._tag_stack.try_pop('caption', ['table']);
2146
- this._tag_stack.try_pop('colgroup', ['table']);
2147
- this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
2575
+ result = result || this._tag_stack.try_pop('caption', ['table']);
2576
+ result = result || this._tag_stack.try_pop('colgroup', ['table']);
2577
+ result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
2148
2578
 
2149
2579
  } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
2150
2580
  // 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.
2151
2581
  // 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.
2152
- this._tag_stack.try_pop('td', ['tr']);
2153
- this._tag_stack.try_pop('th', ['tr']);
2582
+ result = result || this._tag_stack.try_pop('td', ['tr']);
2583
+ result = result || this._tag_stack.try_pop('th', ['tr']);
2154
2584
  }
2155
2585
 
2156
2586
  // Start element omission not handled currently
@@ -2161,13 +2591,14 @@ Beautifier.prototype._do_optional_end_element = function(parser_token) {
2161
2591
  // Fix up the parent of the parser token
2162
2592
  parser_token.parent = this._tag_stack.get_parser_token();
2163
2593
 
2594
+ return result;
2164
2595
  };
2165
2596
 
2166
2597
  module.exports.Beautifier = Beautifier;
2167
2598
 
2168
2599
 
2169
2600
  /***/ }),
2170
- /* 17 */
2601
+ /* 20 */
2171
2602
  /***/ (function(module, exports, __webpack_require__) {
2172
2603
 
2173
2604
  "use strict";
@@ -2261,7 +2692,7 @@ module.exports.Options = Options;
2261
2692
 
2262
2693
 
2263
2694
  /***/ }),
2264
- /* 18 */
2695
+ /* 21 */
2265
2696
  /***/ (function(module, exports, __webpack_require__) {
2266
2697
 
2267
2698
  "use strict";
@@ -2297,8 +2728,9 @@ module.exports.Options = Options;
2297
2728
 
2298
2729
  var BaseTokenizer = __webpack_require__(9).Tokenizer;
2299
2730
  var BASETOKEN = __webpack_require__(9).TOKEN;
2300
- var Directives = __webpack_require__(11).Directives;
2301
- var TemplatableReader = __webpack_require__(19).TemplatableReader;
2731
+ var Directives = __webpack_require__(13).Directives;
2732
+ var TemplatablePattern = __webpack_require__(14).TemplatablePattern;
2733
+ var Pattern = __webpack_require__(12).Pattern;
2302
2734
 
2303
2735
  var TOKEN = {
2304
2736
  TAG_OPEN: 'TK_TAG_OPEN',
@@ -2322,18 +2754,38 @@ var Tokenizer = function(input_string, options) {
2322
2754
 
2323
2755
  // Words end at whitespace or when a tag starts
2324
2756
  // if we are indenting handlebars, they are considered tags
2325
- this._word = new TemplatableReader(this._input).until(/[\n\r\t <]/g).with_templates();
2326
- this._word.handlebars = false; // Detect only
2327
- this._single_quote = new TemplatableReader(this._input).until_after(/'/g).with_templates();
2328
- this._double_quote = new TemplatableReader(this._input).until_after(/"/g).with_templates();
2329
- this._attribute = new TemplatableReader(this._input).until(/[\n\r\t =\/>]/g).with_templates();
2330
- this._element_name = new TemplatableReader(this._input).until(/[\n\r\t >\/]/g).with_templates();
2757
+ var templatable_reader = new TemplatablePattern(this._input);
2758
+ var pattern_reader = new Pattern(this._input);
2759
+
2760
+ this.__patterns = {
2761
+ word: templatable_reader.until(/[\n\r\t <]/),
2762
+ single_quote: templatable_reader.until_after(/'/),
2763
+ double_quote: templatable_reader.until_after(/"/),
2764
+ attribute: templatable_reader.until(/[\n\r\t =\/>]/),
2765
+ element_name: templatable_reader.until(/[\n\r\t >\/]/),
2766
+
2767
+ handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
2768
+ handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
2769
+ handlebars_open: pattern_reader.until(/[\n\r\t }]/),
2770
+ handlebars_raw_close: pattern_reader.until(/}}/),
2771
+ comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
2772
+ cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
2773
+ // https://en.wikipedia.org/wiki/Conditional_comment
2774
+ conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
2775
+ processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
2776
+ };
2777
+
2778
+ if (this._options.indent_handlebars) {
2779
+ this.__patterns.word = this.__patterns.word.exclude('handlebars');
2780
+ }
2781
+
2331
2782
  this._unformatted_content_delimiter = null;
2332
2783
 
2333
2784
  if (this._options.unformatted_content_delimiter) {
2334
- this._unformatted_content_delimiter =
2335
- new RegExp(this._options.unformatted_content_delimiter
2336
- .replace(/([[\\^$.|?*+()])/g, '\\$1'), 'g');
2785
+ var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
2786
+ this.__patterns.unformatted_content_delimiter =
2787
+ pattern_reader.matching(literal_regexp)
2788
+ .until_after(literal_regexp);
2337
2789
  }
2338
2790
  };
2339
2791
  Tokenizer.prototype = new BaseTokenizer();
@@ -2358,8 +2810,8 @@ Tokenizer.prototype._reset = function() {
2358
2810
  };
2359
2811
 
2360
2812
  Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
2361
- this._readWhitespace();
2362
2813
  var token = null;
2814
+ this._readWhitespace();
2363
2815
  var c = this._input.peek();
2364
2816
 
2365
2817
  if (c === null) {
@@ -2389,7 +2841,7 @@ Tokenizer.prototype._read_comment = function(c) { // jshint unused:false
2389
2841
  // We treat all comments as literals, even more than preformatted tags
2390
2842
  // we just look for the appropriate close tag
2391
2843
  if (c === '<' && (peek1 === '!' || peek1 === '?')) {
2392
- resulting_string = this._input.read(/<!--/g, /-->/g);
2844
+ resulting_string = this.__patterns.comment.read();
2393
2845
 
2394
2846
  // only process directive on html comments
2395
2847
  if (resulting_string) {
@@ -2398,9 +2850,9 @@ Tokenizer.prototype._read_comment = function(c) { // jshint unused:false
2398
2850
  resulting_string += directives_core.readIgnored(this._input);
2399
2851
  }
2400
2852
  } else {
2401
- resulting_string = this._input.read(/<!\[cdata\[/g, /]]>/g);
2402
- resulting_string = resulting_string || this._input.read(/<!\[/g, /]>/g);
2403
- resulting_string = resulting_string || this._input.read(/<\?/g, /\?>/g);
2853
+ resulting_string = this.__patterns.cdata.read();
2854
+ resulting_string = resulting_string || this.__patterns.conditional_comment.read();
2855
+ resulting_string = resulting_string || this.__patterns.processing.read();
2404
2856
  }
2405
2857
  }
2406
2858
 
@@ -2423,7 +2875,7 @@ Tokenizer.prototype._read_open = function(c, open_token) {
2423
2875
  if (this._input.peek() === '/') {
2424
2876
  resulting_string += this._input.next();
2425
2877
  }
2426
- resulting_string += this._element_name.read();
2878
+ resulting_string += this.__patterns.element_name.read();
2427
2879
  token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
2428
2880
  }
2429
2881
  }
@@ -2436,11 +2888,11 @@ Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
2436
2888
  if (!open_token) {
2437
2889
  if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
2438
2890
  if (this._input.peek(2) === '!') {
2439
- resulting_string = this._input.read(/{{!--/g, /--}}/g);
2440
- resulting_string = resulting_string || this._input.read(/{{/g, /}}/g);
2891
+ resulting_string = this.__patterns.handlebars_comment.read();
2892
+ resulting_string = resulting_string || this.__patterns.handlebars.read();
2441
2893
  token = this._create_token(TOKEN.COMMENT, resulting_string);
2442
2894
  } else {
2443
- resulting_string = this._input.readUntil(/[\n\r\t }]/g);
2895
+ resulting_string = this.__patterns.handlebars_open.read();
2444
2896
  token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
2445
2897
  }
2446
2898
  }
@@ -2479,13 +2931,13 @@ Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) {
2479
2931
  } else if (c === '"' || c === "'") {
2480
2932
  var content = this._input.next();
2481
2933
  if (c === '"') {
2482
- content += this._double_quote.read();
2934
+ content += this.__patterns.double_quote.read();
2483
2935
  } else {
2484
- content += this._single_quote.read();
2936
+ content += this.__patterns.single_quote.read();
2485
2937
  }
2486
2938
  token = this._create_token(TOKEN.VALUE, content);
2487
2939
  } else {
2488
- resulting_string = this._attribute.read();
2940
+ resulting_string = this.__patterns.attribute.read();
2489
2941
 
2490
2942
  if (resulting_string) {
2491
2943
  if (previous_token.type === TOKEN.EQUALS) {
@@ -2513,7 +2965,7 @@ Tokenizer.prototype._is_content_unformatted = function(tag_name) {
2513
2965
  Tokenizer.prototype._read_raw_content = function(previous_token, open_token) { // jshint unused:false
2514
2966
  var resulting_string = '';
2515
2967
  if (open_token && open_token.text[0] === '{') {
2516
- resulting_string = this._input.readUntil(/}}/g);
2968
+ resulting_string = this.__patterns.handlebars_raw_close.read();
2517
2969
  } else if (previous_token.type === TOKEN.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
2518
2970
  var tag_name = previous_token.opened.text.substr(1).toLowerCase();
2519
2971
  if (this._is_content_unformatted(tag_name)) {
@@ -2530,19 +2982,14 @@ Tokenizer.prototype._read_raw_content = function(previous_token, open_token) { /
2530
2982
 
2531
2983
  Tokenizer.prototype._read_content_word = function(c) {
2532
2984
  var resulting_string = '';
2533
- if (this._unformatted_content_delimiter) {
2985
+ if (this._options.unformatted_content_delimiter) {
2534
2986
  if (c === this._options.unformatted_content_delimiter[0]) {
2535
- resulting_string = this._input.read(this._unformatted_content_delimiter);
2987
+ resulting_string = this.__patterns.unformatted_content_delimiter.read();
2536
2988
  }
2537
2989
  }
2538
2990
 
2539
- if (resulting_string) {
2540
- resulting_string += this._input.readUntilAfter(this._unformatted_content_delimiter);
2541
- } else {
2542
- if (c === '{' && !this._options.indent_handlebars) {
2543
- resulting_string += this._input.next();
2544
- }
2545
- resulting_string += this._word.read();
2991
+ if (!resulting_string) {
2992
+ resulting_string = this.__patterns.word.read();
2546
2993
  }
2547
2994
  if (resulting_string) {
2548
2995
  return this._create_token(TOKEN.TEXT, resulting_string);
@@ -2553,173 +3000,6 @@ module.exports.Tokenizer = Tokenizer;
2553
3000
  module.exports.TOKEN = TOKEN;
2554
3001
 
2555
3002
 
2556
- /***/ }),
2557
- /* 19 */
2558
- /***/ (function(module, exports, __webpack_require__) {
2559
-
2560
- "use strict";
2561
- /*jshint node:true */
2562
- /*
2563
-
2564
- The MIT License (MIT)
2565
-
2566
- Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2567
-
2568
- Permission is hereby granted, free of charge, to any person
2569
- obtaining a copy of this software and associated documentation files
2570
- (the "Software"), to deal in the Software without restriction,
2571
- including without limitation the rights to use, copy, modify, merge,
2572
- publish, distribute, sublicense, and/or sell copies of the Software,
2573
- and to permit persons to whom the Software is furnished to do so,
2574
- subject to the following conditions:
2575
-
2576
- The above copyright notice and this permission notice shall be
2577
- included in all copies or substantial portions of the Software.
2578
-
2579
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2580
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2581
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2582
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2583
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2584
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2585
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2586
- SOFTWARE.
2587
- */
2588
-
2589
-
2590
-
2591
- function PatternReader(input_scanner) {
2592
- this._input = input_scanner;
2593
- this._until_pattern = null;
2594
- this._from_pattern = null;
2595
- this._include_match = false;
2596
- }
2597
-
2598
- PatternReader.prototype.read = function() {
2599
- var result = '';
2600
- if (this._from_pattern) {
2601
- result = this._input.read(this._from_pattern, this._until_pattern, this._include_match);
2602
- } else {
2603
- result = this._input.readUntil(this._until_pattern, this._include_match);
2604
- }
2605
- return result;
2606
- };
2607
-
2608
- PatternReader.prototype.until_after = function(pattern) {
2609
- this.include_match = true;
2610
- this._until_pattern = pattern;
2611
- return this;
2612
- };
2613
-
2614
- PatternReader.prototype.until = function(pattern) {
2615
- this.include_match = false;
2616
- this._until_pattern = pattern;
2617
- return this;
2618
- };
2619
-
2620
- PatternReader.prototype.from = function(pattern) {
2621
- this._from_pattern = pattern;
2622
- return this;
2623
- };
2624
-
2625
- function TemplatableReader(input_scanner) {
2626
- PatternReader.call(this, input_scanner);
2627
- this.__template_pattern = null;
2628
- this.handlebars = true;
2629
- this.php = true;
2630
- this.asp = true;
2631
- this.__language = {
2632
- handlebars_comment: new PatternReader(input_scanner).from(/{{!--/g).until_after(/--}}/g),
2633
- handlebars: new PatternReader(input_scanner).from(/{{/g).until_after(/}}/g),
2634
- php: new PatternReader(input_scanner).from(/<\?(?:[=]|php)/g).until_after(/\?>/g),
2635
- asp: new PatternReader(input_scanner).from(/<%/g).until_after(/%>/g)
2636
- };
2637
- }
2638
- TemplatableReader.prototype = new PatternReader();
2639
-
2640
- // This lets templates appear anywhere we would do a readUntil
2641
- // The cost is higher but it is pay to play.
2642
- TemplatableReader.prototype.with_templates = function() {
2643
- this.__set_templated_pattern();
2644
- return this;
2645
- };
2646
-
2647
- TemplatableReader.prototype.read = function() {
2648
- var result;
2649
- if (this._from_pattern) {
2650
- result = this._input.read(this._from_pattern, this.__template_pattern);
2651
- } else {
2652
- result = this._input.readUntil(this.__template_pattern);
2653
- }
2654
- var next = '';
2655
- do {
2656
- result += next;
2657
- next = this.read_template();
2658
- if (next !== '') {
2659
- next += this._input.readUntil(this.__template_pattern);
2660
- }
2661
- } while (this._input.hasNext() && next !== '');
2662
- result += next;
2663
-
2664
- if (this.include_match) {
2665
- result += this._input.readUntilAfter(this._until_pattern);
2666
- }
2667
- return result;
2668
- };
2669
-
2670
- TemplatableReader.prototype.__set_templated_pattern = function() {
2671
- var items = [];
2672
-
2673
- if (this._until_pattern) {
2674
- items.push(this._until_pattern.source);
2675
- }
2676
-
2677
- if (this.php) {
2678
- items.push(this.__language.php._from_pattern.source);
2679
- }
2680
-
2681
- if (this.handlebars) {
2682
- items.push(this.__language.handlebars._from_pattern.source);
2683
- }
2684
-
2685
- if (this.asp) {
2686
- items.push(this.__language.asp._from_pattern.source);
2687
- }
2688
-
2689
- this.__template_pattern = new RegExp('(?:' + items.join('|') + ')', 'g');
2690
- };
2691
-
2692
- TemplatableReader.prototype.read_template = function() {
2693
- var resulting_string = '';
2694
- var c = this._input.peek();
2695
- if (c === '<') {
2696
- var peek1 = this._input.peek(1);
2697
- //if we're in a comment, do something special
2698
- // We treat all comments as literals, even more than preformatted tags
2699
- // we just look for the appropriate close tag
2700
- if (this.php && peek1 === '?') {
2701
- resulting_string = resulting_string ||
2702
- this.__language.php.read();
2703
- }
2704
- if (this.asp && peek1 === '%') {
2705
- resulting_string = resulting_string ||
2706
- this.__language.asp.read();
2707
- }
2708
- } else if (c === '{') {
2709
- if (this.handlebars) {
2710
- resulting_string = resulting_string ||
2711
- this.__language.handlebars_comment.read();
2712
- resulting_string = resulting_string ||
2713
- this.__language.handlebars.read();
2714
- }
2715
- }
2716
- return resulting_string;
2717
- };
2718
-
2719
-
2720
- module.exports.TemplatableReader = TemplatableReader;
2721
-
2722
-
2723
3003
  /***/ })
2724
3004
  /******/ ]);
2725
3005
  var style_html = legacy_beautify_html;