|
392 | 392 | }, {
|
393 | 393 | key: 'parseBlock',
|
394 | 394 | value: function parseBlock(text, lines) {
|
| 395 | + var _this4 = this; |
| 396 | + |
395 | 397 | this.blocks = [];
|
396 | 398 | this.current = 'normal';
|
397 | 399 | this.pos = -1;
|
|
504 | 506 | case /^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+)|(?:(?:[ :]*\-[ :]*)+(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/g.test(line):
|
505 | 507 | var tableMatches = /^((?:(?:(?:[ :]*\-[ :]*)+(?:\||\+))|(?:(?:\||\+)(?:[ :]*\-[ :]*)+)|(?:(?:[ :]*\-[ :]*)+(?:\||\+)(?:[ :]*\-[ :]*)+))+)$/g.exec(line);
|
506 | 508 | if (this.isBlock('normal')) {
|
507 |
| - var block = this.getBlock(); |
508 |
| - var head = false; |
509 |
| - |
510 |
| - if (block.length === 0 || block[0] !== 'normal' || /^\s*$/.test(lines[block[2]])) { |
511 |
| - this.startBlock('table', key); |
512 |
| - } else { |
513 |
| - head = true; |
514 |
| - this.backBlock(1, 'table'); |
515 |
| - } |
516 |
| - |
517 |
| - if (tableMatches[1][0] == '|') { |
518 |
| - tableMatches[1] = tableMatches[1].substr(1); |
| 509 | + (function () { |
| 510 | + var block = _this4.getBlock(); |
| 511 | + var head = false; |
519 | 512 |
|
520 |
| - if (tableMatches[1][tableMatches[1].length - 1] == '|') { |
521 |
| - tableMatches[1] = tableMatches[1].slice(0, -1); |
| 513 | + if (block.length === 0 || block[0] !== 'normal' || /^\s*$/.test(lines[block[2]])) { |
| 514 | + _this4.startBlock('table', key); |
| 515 | + } else { |
| 516 | + head = true; |
| 517 | + _this4.backBlock(1, 'table'); |
522 | 518 | }
|
523 |
| - } |
524 | 519 |
|
525 |
| - var rows = tableMatches[1].split(/(\+|\|)/); |
526 |
| - var aligns = []; |
527 |
| - var _iteratorNormalCompletion = true; |
528 |
| - var _didIteratorError = false; |
529 |
| - var _iteratorError = undefined; |
| 520 | + if (tableMatches[1][0] == '|') { |
| 521 | + tableMatches[1] = tableMatches[1].substr(1); |
530 | 522 |
|
531 |
| - try { |
532 |
| - for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
533 |
| - var row = _step.value; |
| 523 | + if (tableMatches[1][tableMatches[1].length - 1] == '|') { |
| 524 | + tableMatches[1] = tableMatches[1].slice(0, -1); |
| 525 | + } |
| 526 | + } |
534 | 527 |
|
| 528 | + var rows = tableMatches[1].split(/(\+|\|)/); |
| 529 | + var aligns = []; |
| 530 | + rows.forEach(function (row) { |
535 | 531 | var align = 'none';
|
536 | 532 |
|
537 | 533 | if (tableMatches = row.match(/^\s*(:?)\-+(:?)\s*$/)) {
|
|
545 | 541 | }
|
546 | 542 |
|
547 | 543 | aligns.push(align);
|
548 |
| - } |
549 |
| - } catch (err) { |
550 |
| - _didIteratorError = true; |
551 |
| - _iteratorError = err; |
552 |
| - } finally { |
553 |
| - try { |
554 |
| - if (!_iteratorNormalCompletion && _iterator['return']) { |
555 |
| - _iterator['return'](); |
556 |
| - } |
557 |
| - } finally { |
558 |
| - if (_didIteratorError) { |
559 |
| - throw _iteratorError; |
560 |
| - } |
561 |
| - } |
562 |
| - } |
| 544 | + }); |
563 | 545 |
|
564 |
| - this.setBlock(key, [head, aligns]); |
| 546 | + _this4.setBlock(key, [head, aligns]); |
| 547 | + })(); |
565 | 548 | }
|
566 | 549 | break;
|
567 | 550 |
|
|
734 | 717 | }, {
|
735 | 718 | key: 'parsePre',
|
736 | 719 | value: function parsePre(lines) {
|
737 |
| - var _this4 = this; |
| 720 | + var _this5 = this; |
738 | 721 |
|
739 | 722 | lines.forEach(function (line, ind) {
|
740 |
| - lines[ind] = _this4.htmlspecialchars(line.substr(4)); |
| 723 | + lines[ind] = _this5.htmlspecialchars(line.substr(4)); |
741 | 724 | });
|
742 | 725 | var str = lines.join('\n');
|
743 | 726 |
|
|
809 | 792 | }, {
|
810 | 793 | key: 'parseList',
|
811 | 794 | value: function parseList(lines) {
|
812 |
| - var _this5 = this; |
| 795 | + var _this6 = this; |
813 | 796 |
|
814 | 797 | var html = '';
|
815 | 798 | var minSpace = 99999;
|
|
864 | 847 | }
|
865 | 848 |
|
866 | 849 | if (leftLines.length) {
|
867 |
| - html += "<li>" + _this5.parse(leftLines.join("\n")) + "</li>"; |
| 850 | + html += "<li>" + _this6.parse(leftLines.join("\n")) + "</li>"; |
868 | 851 | }
|
869 | 852 |
|
870 | 853 | leftLines = [text];
|
|
891 | 874 | }, {
|
892 | 875 | key: 'parseTable',
|
893 | 876 | value: function parseTable(lines, value) {
|
894 |
| - var _this6 = this; |
| 877 | + var _this7 = this; |
895 | 878 |
|
896 | 879 | var _value = _slicedToArray(value, 2);
|
897 | 880 |
|
|
970 | 953 | html += ' align="' + aligns[key] + '"';
|
971 | 954 | }
|
972 | 955 |
|
973 |
| - html += '>' + _this6.parseInline(text) + ('</' + tag + '>'); |
| 956 | + html += '>' + _this7.parseInline(text) + ('</' + tag + '>'); |
974 | 957 | });
|
975 | 958 |
|
976 | 959 | html += '</tr>';
|
|
983 | 966 | };
|
984 | 967 |
|
985 | 968 | for (var key in lines) {
|
986 |
| - var _ret = _loop(key); |
| 969 | + var _ret2 = _loop(key); |
987 | 970 |
|
988 |
| - if (_ret === 'continue') continue; |
| 971 | + if (_ret2 === 'continue') continue; |
989 | 972 | }
|
990 | 973 |
|
991 | 974 | if (body !== null) {
|
|
1016 | 999 | }, {
|
1017 | 1000 | key: 'parseNormal',
|
1018 | 1001 | value: function parseNormal(lines) {
|
1019 |
| - var _this7 = this; |
| 1002 | + var _this8 = this; |
1020 | 1003 |
|
1021 | 1004 | lines = lines.map(function (line) {
|
1022 |
| - return _this7.parseInline(line); |
| 1005 | + return _this8.parseInline(line); |
1023 | 1006 | });
|
1024 | 1007 |
|
1025 | 1008 | var str = lines.join("\n").trim();
|
|
1077 | 1060 | }, {
|
1078 | 1061 | key: 'parseHtml',
|
1079 | 1062 | value: function parseHtml(lines, type) {
|
1080 |
| - var _this8 = this; |
| 1063 | + var _this9 = this; |
1081 | 1064 |
|
1082 | 1065 | lines.forEach(function (line) {
|
1083 |
| - line = _this8.parseInline(line, _this8.specialWhiteList[type] ? _this8.specialWhiteList[type] : ''); |
| 1066 | + line = _this9.parseInline(line, _this9.specialWhiteList[type] ? _this9.specialWhiteList[type] : ''); |
1084 | 1067 | });
|
1085 | 1068 |
|
1086 | 1069 | return lines.join("\n");
|
|
0 commit comments