@subiz/widget-v4 4.0.91 → 4.0.92

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.
Files changed (69) hide show
  1. package/compiled_src/chatbox/main.js +2 -3
  2. package/compiled_src/store/api.js +4 -1
  3. package/compiled_src/store/store.js +4 -9
  4. package/compiled_src/util/common.js +0 -5
  5. package/dist/132.js +405 -90
  6. package/dist/178.js +174 -341
  7. package/dist/18364d15f37.132.js +1 -0
  8. package/dist/18364d15f37.178.js +1 -0
  9. package/dist/{17f00e48d38.213.js → 18364d15f37.213.js} +1 -1
  10. package/dist/{17f00e48d38.335.js → 18364d15f37.335.js} +1 -1
  11. package/dist/18364d15f37.362.js +1 -0
  12. package/dist/18364d15f37.441.js +1 -0
  13. package/dist/{17f00e48d38.605.js → 18364d15f37.605.js} +0 -0
  14. package/dist/18364d15f37.678.js +1 -0
  15. package/dist/18364d15f37.782.js +1 -0
  16. package/dist/18364d15f37.app.js +1 -0
  17. package/dist/{17f00e48d38.index.html → 18364d15f37.index.html} +7 -3
  18. package/dist/{17f00e48d38.library.html → 18364d15f37.library.html} +7 -3
  19. package/dist/18364d15f37.library.js +1 -0
  20. package/dist/{17f00e48d38.preview.html → 18364d15f37.preview.html} +1 -1
  21. package/dist/18364d15f37.preview.js +1 -0
  22. package/dist/18364d15f37.screenshoot.js +1 -0
  23. package/dist/213.js +28 -1
  24. package/dist/335.js +2 -2
  25. package/dist/362.js +21 -71
  26. package/dist/441.js +202 -100
  27. package/dist/678.js +20 -70
  28. package/dist/782.js +21 -118
  29. package/dist/HASH +1 -1
  30. package/dist/screenshoot.html +1 -1
  31. package/dist/screenshoot.js +209 -175
  32. package/package.json +8 -8
  33. package/src/chatbox/main.js +3 -3
  34. package/src/store/api.js +1 -1
  35. package/src/store/store.js +7 -9
  36. package/src/util/common.js +0 -4
  37. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  38. package/dist/0f4af006e38ee8b93633.png +0 -1
  39. package/dist/17f00e48d38.132.js +0 -1
  40. package/dist/17f00e48d38.178.js +0 -1
  41. package/dist/17f00e48d38.362.js +0 -1
  42. package/dist/17f00e48d38.441.js +0 -1
  43. package/dist/17f00e48d38.678.js +0 -1
  44. package/dist/17f00e48d38.782.js +0 -1
  45. package/dist/17f00e48d38.app.js +0 -1
  46. package/dist/17f00e48d38.library.js +0 -1
  47. package/dist/17f00e48d38.preview.js +0 -1
  48. package/dist/17f00e48d38.screenshoot.js +0 -1
  49. package/dist/1ea1c6cd21d25176810c.png +0 -1
  50. package/dist/292d42404e1b03398f61.png +0 -1
  51. package/dist/312d376370831b7bea83.png +0 -1
  52. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  53. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  54. package/dist/56ce063bc6c81adb7322.png +0 -1
  55. package/dist/6a411166ef5cc79e0714.png +0 -1
  56. package/dist/6faf403782fefacc1649.png +0 -1
  57. package/dist/79dca33c68fab79c067f.png +0 -1
  58. package/dist/82da1578fa84f9debaeb.png +0 -1
  59. package/dist/8b8e0f0824743974b282.png +0 -1
  60. package/dist/8d551390d81e39130a3c.png +0 -1
  61. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  62. package/dist/a165d31dcb3dc90f1057.png +0 -1
  63. package/dist/a98d4a5698812c4426b3.png +0 -1
  64. package/dist/c41606bf9d1b604e46d5.png +0 -1
  65. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  66. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  67. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  68. package/dist/e4893ed8c2f7b8329919.png +0 -1
  69. package/dist/ec2ab4eb4ef73d186186.png +0 -1
package/dist/441.js CHANGED
@@ -37,6 +37,7 @@ __webpack_require__.r(__webpack_exports__);
37
37
 
38
38
  function getDefaults() {
39
39
  return {
40
+ async: false,
40
41
  baseUrl: null,
41
42
  breaks: false,
42
43
  extensions: null,
@@ -96,6 +97,9 @@ function escape(html, encode) {
96
97
 
97
98
  const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
98
99
 
100
+ /**
101
+ * @param {string} html
102
+ */
99
103
  function unescape(html) {
100
104
  // explicitly match decimal, hex, and named HTML entities
101
105
  return html.replace(unescapeTest, (_, n) => {
@@ -111,8 +115,13 @@ function unescape(html) {
111
115
  }
112
116
 
113
117
  const caret = /(^|[^\[])\^/g;
118
+
119
+ /**
120
+ * @param {string | RegExp} regex
121
+ * @param {string} opt
122
+ */
114
123
  function edit(regex, opt) {
115
- regex = regex.source || regex;
124
+ regex = typeof regex === 'string' ? regex : regex.source;
116
125
  opt = opt || '';
117
126
  const obj = {
118
127
  replace: (name, val) => {
@@ -130,6 +139,12 @@ function edit(regex, opt) {
130
139
 
131
140
  const nonWordAndColonTest = /[^\w:]/g;
132
141
  const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
142
+
143
+ /**
144
+ * @param {boolean} sanitize
145
+ * @param {string} base
146
+ * @param {string} href
147
+ */
133
148
  function cleanUrl(sanitize, base, href) {
134
149
  if (sanitize) {
135
150
  let prot;
@@ -160,6 +175,10 @@ const justDomain = /^[^:]+:\/*[^/]*$/;
160
175
  const protocol = /^([^:]+:)[\s\S]*$/;
161
176
  const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
162
177
 
178
+ /**
179
+ * @param {string} base
180
+ * @param {string} href
181
+ */
163
182
  function resolveUrl(base, href) {
164
183
  if (!baseUrls[' ' + base]) {
165
184
  // we can ignore everything in base after the last slash of its path component,
@@ -244,9 +263,14 @@ function splitCells(tableRow, count) {
244
263
  return cells;
245
264
  }
246
265
 
247
- // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
248
- // /c*$/ is vulnerable to REDOS.
249
- // invert: Remove suffix of non-c chars instead. Default falsey.
266
+ /**
267
+ * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
268
+ * /c*$/ is vulnerable to REDOS.
269
+ *
270
+ * @param {string} str
271
+ * @param {string} c
272
+ * @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
273
+ */
250
274
  function rtrim(str, c, invert) {
251
275
  const l = str.length;
252
276
  if (l === 0) {
@@ -268,7 +292,7 @@ function rtrim(str, c, invert) {
268
292
  }
269
293
  }
270
294
 
271
- return str.substr(0, l - suffLen);
295
+ return str.slice(0, l - suffLen);
272
296
  }
273
297
 
274
298
  function findClosingBracket(str, b) {
@@ -300,6 +324,10 @@ function checkSanitizeDeprecation(opt) {
300
324
  }
301
325
 
302
326
  // copied from https://stackoverflow.com/a/5450113/806777
327
+ /**
328
+ * @param {string} pattern
329
+ * @param {number} count
330
+ */
303
331
  function repeatString(pattern, count) {
304
332
  if (count < 1) {
305
333
  return '';
@@ -328,19 +356,18 @@ function outputLink(cap, link, raw, lexer) {
328
356
  href,
329
357
  title,
330
358
  text,
331
- tokens: lexer.inlineTokens(text, [])
359
+ tokens: lexer.inlineTokens(text)
332
360
  };
333
361
  lexer.state.inLink = false;
334
362
  return token;
335
- } else {
336
- return {
337
- type: 'image',
338
- raw,
339
- href,
340
- title,
341
- text: escape(text)
342
- };
343
363
  }
364
+ return {
365
+ type: 'image',
366
+ raw,
367
+ href,
368
+ title,
369
+ text: escape(text)
370
+ };
344
371
  }
345
372
 
346
373
  function indentCodeCompensation(raw, text) {
@@ -435,15 +462,13 @@ class Tokenizer {
435
462
  }
436
463
  }
437
464
 
438
- const token = {
465
+ return {
439
466
  type: 'heading',
440
467
  raw: cap[0],
441
468
  depth: cap[1].length,
442
- text: text,
443
- tokens: []
469
+ text,
470
+ tokens: this.lexer.inline(text)
444
471
  };
445
- this.lexer.inline(token.text, token.tokens);
446
- return token;
447
472
  }
448
473
  }
449
474
 
@@ -460,7 +485,7 @@ class Tokenizer {
460
485
  blockquote(src) {
461
486
  const cap = this.rules.block.blockquote.exec(src);
462
487
  if (cap) {
463
- const text = cap[0].replace(/^ *> ?/gm, '');
488
+ const text = cap[0].replace(/^ *>[ \t]?/gm, '');
464
489
 
465
490
  return {
466
491
  type: 'blockquote',
@@ -496,7 +521,7 @@ class Tokenizer {
496
521
  }
497
522
 
498
523
  // Get next list item
499
- const itemRegex = new RegExp(`^( {0,3}${bull})((?: [^\\n]*)?(?:\\n|$))`);
524
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
500
525
 
501
526
  // Check if current bullet point can start a new List Item
502
527
  while (src) {
@@ -534,7 +559,10 @@ class Tokenizer {
534
559
  }
535
560
 
536
561
  if (!endEarly) {
537
- const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`);
562
+ const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
563
+ const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
564
+ const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
565
+ const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
538
566
 
539
567
  // Check if following lines should be included in List Item
540
568
  while (src) {
@@ -546,11 +574,26 @@ class Tokenizer {
546
574
  line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
547
575
  }
548
576
 
577
+ // End list item if found code fences
578
+ if (fencesBeginRegex.test(line)) {
579
+ break;
580
+ }
581
+
582
+ // End list item if found start of new heading
583
+ if (headingBeginRegex.test(line)) {
584
+ break;
585
+ }
586
+
549
587
  // End list item if found start of new bullet
550
588
  if (nextBulletRegex.test(line)) {
551
589
  break;
552
590
  }
553
591
 
592
+ // Horizontal rule found
593
+ if (hrRegex.test(src)) {
594
+ break;
595
+ }
596
+
554
597
  if (line.search(/[^ ]/) >= indent || !line.trim()) { // Dedent if possible
555
598
  itemContents += '\n' + line.slice(indent);
556
599
  } else if (!blankLine) { // Until blank line, item doesn't need indentation
@@ -588,7 +631,7 @@ class Tokenizer {
588
631
 
589
632
  list.items.push({
590
633
  type: 'list_item',
591
- raw: raw,
634
+ raw,
592
635
  task: !!istask,
593
636
  checked: ischecked,
594
637
  loose: false,
@@ -647,10 +690,10 @@ class Tokenizer {
647
690
  text: cap[0]
648
691
  };
649
692
  if (this.options.sanitize) {
693
+ const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
650
694
  token.type = 'paragraph';
651
- token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
652
- token.tokens = [];
653
- this.lexer.inline(token.text, token.tokens);
695
+ token.text = text;
696
+ token.tokens = this.lexer.inline(text);
654
697
  }
655
698
  return token;
656
699
  }
@@ -708,8 +751,7 @@ class Tokenizer {
708
751
  // header child tokens
709
752
  l = item.header.length;
710
753
  for (j = 0; j < l; j++) {
711
- item.header[j].tokens = [];
712
- this.lexer.inlineTokens(item.header[j].text, item.header[j].tokens);
754
+ item.header[j].tokens = this.lexer.inline(item.header[j].text);
713
755
  }
714
756
 
715
757
  // cell child tokens
@@ -717,8 +759,7 @@ class Tokenizer {
717
759
  for (j = 0; j < l; j++) {
718
760
  row = item.rows[j];
719
761
  for (k = 0; k < row.length; k++) {
720
- row[k].tokens = [];
721
- this.lexer.inlineTokens(row[k].text, row[k].tokens);
762
+ row[k].tokens = this.lexer.inline(row[k].text);
722
763
  }
723
764
  }
724
765
 
@@ -730,45 +771,40 @@ class Tokenizer {
730
771
  lheading(src) {
731
772
  const cap = this.rules.block.lheading.exec(src);
732
773
  if (cap) {
733
- const token = {
774
+ return {
734
775
  type: 'heading',
735
776
  raw: cap[0],
736
777
  depth: cap[2].charAt(0) === '=' ? 1 : 2,
737
778
  text: cap[1],
738
- tokens: []
779
+ tokens: this.lexer.inline(cap[1])
739
780
  };
740
- this.lexer.inline(token.text, token.tokens);
741
- return token;
742
781
  }
743
782
  }
744
783
 
745
784
  paragraph(src) {
746
785
  const cap = this.rules.block.paragraph.exec(src);
747
786
  if (cap) {
748
- const token = {
787
+ const text = cap[1].charAt(cap[1].length - 1) === '\n'
788
+ ? cap[1].slice(0, -1)
789
+ : cap[1];
790
+ return {
749
791
  type: 'paragraph',
750
792
  raw: cap[0],
751
- text: cap[1].charAt(cap[1].length - 1) === '\n'
752
- ? cap[1].slice(0, -1)
753
- : cap[1],
754
- tokens: []
793
+ text,
794
+ tokens: this.lexer.inline(text)
755
795
  };
756
- this.lexer.inline(token.text, token.tokens);
757
- return token;
758
796
  }
759
797
  }
760
798
 
761
799
  text(src) {
762
800
  const cap = this.rules.block.text.exec(src);
763
801
  if (cap) {
764
- const token = {
802
+ return {
765
803
  type: 'text',
766
804
  raw: cap[0],
767
805
  text: cap[0],
768
- tokens: []
806
+ tokens: this.lexer.inline(cap[0])
769
807
  };
770
- this.lexer.inline(token.text, token.tokens);
771
- return token;
772
808
  }
773
809
  }
774
810
 
@@ -937,7 +973,7 @@ class Tokenizer {
937
973
  type: 'em',
938
974
  raw: src.slice(0, lLength + match.index + rLength + 1),
939
975
  text,
940
- tokens: this.lexer.inlineTokens(text, [])
976
+ tokens: this.lexer.inlineTokens(text)
941
977
  };
942
978
  }
943
979
 
@@ -947,7 +983,7 @@ class Tokenizer {
947
983
  type: 'strong',
948
984
  raw: src.slice(0, lLength + match.index + rLength + 1),
949
985
  text,
950
- tokens: this.lexer.inlineTokens(text, [])
986
+ tokens: this.lexer.inlineTokens(text)
951
987
  };
952
988
  }
953
989
  }
@@ -988,7 +1024,7 @@ class Tokenizer {
988
1024
  type: 'del',
989
1025
  raw: cap[0],
990
1026
  text: cap[2],
991
- tokens: this.lexer.inlineTokens(cap[2], [])
1027
+ tokens: this.lexer.inlineTokens(cap[2])
992
1028
  };
993
1029
  }
994
1030
  }
@@ -1083,10 +1119,10 @@ const block = {
1083
1119
  newline: /^(?: *(?:\n|$))+/,
1084
1120
  code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
1085
1121
  fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
1086
- hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
1122
+ hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
1087
1123
  heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
1088
1124
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
1089
- list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
1125
+ list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
1090
1126
  html: '^ {0,3}(?:' // optional indentation
1091
1127
  + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
1092
1128
  + '|comment[^\\n]*(\\n+|$)' // (2)
@@ -1240,9 +1276,9 @@ const inline = {
1240
1276
  emStrong: {
1241
1277
  lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
1242
1278
  // (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
1243
- // () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1244
- rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
1245
- rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
1279
+ // () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1280
+ rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
1281
+ rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
1246
1282
  },
1247
1283
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1248
1284
  br: /^( {2,}|\\)\n(?!\s*$)/,
@@ -1375,6 +1411,7 @@ inline.breaks = merge({}, inline.gfm, {
1375
1411
 
1376
1412
  /**
1377
1413
  * smartypants text replacement
1414
+ * @param {string} text
1378
1415
  */
1379
1416
  function smartypants(text) {
1380
1417
  return text
@@ -1396,6 +1433,7 @@ function smartypants(text) {
1396
1433
 
1397
1434
  /**
1398
1435
  * mangle email addresses
1436
+ * @param {string} text
1399
1437
  */
1400
1438
  function mangle(text) {
1401
1439
  let out = '',
@@ -1483,8 +1521,7 @@ class Lexer {
1483
1521
  */
1484
1522
  lex(src) {
1485
1523
  src = src
1486
- .replace(/\r\n|\r/g, '\n')
1487
- .replace(/\t/g, ' ');
1524
+ .replace(/\r\n|\r/g, '\n');
1488
1525
 
1489
1526
  this.blockTokens(src, this.tokens);
1490
1527
 
@@ -1501,8 +1538,13 @@ class Lexer {
1501
1538
  */
1502
1539
  blockTokens(src, tokens = []) {
1503
1540
  if (this.options.pedantic) {
1504
- src = src.replace(/^ +$/gm, '');
1541
+ src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
1542
+ } else {
1543
+ src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1544
+ return leading + ' '.repeat(tabs.length);
1545
+ });
1505
1546
  }
1547
+
1506
1548
  let token, lastToken, cutSrc, lastParagraphClipped;
1507
1549
 
1508
1550
  while (src) {
@@ -1680,8 +1722,9 @@ class Lexer {
1680
1722
  return tokens;
1681
1723
  }
1682
1724
 
1683
- inline(src, tokens) {
1725
+ inline(src, tokens = []) {
1684
1726
  this.inlineQueue.push({ src, tokens });
1727
+ return tokens;
1685
1728
  }
1686
1729
 
1687
1730
  /**
@@ -1898,29 +1941,31 @@ class Renderer {
1898
1941
  + '</code></pre>\n';
1899
1942
  }
1900
1943
 
1944
+ /**
1945
+ * @param {string} quote
1946
+ */
1901
1947
  blockquote(quote) {
1902
- return '<blockquote>\n' + quote + '</blockquote>\n';
1948
+ return `<blockquote>\n${quote}</blockquote>\n`;
1903
1949
  }
1904
1950
 
1905
1951
  html(html) {
1906
1952
  return html;
1907
1953
  }
1908
1954
 
1955
+ /**
1956
+ * @param {string} text
1957
+ * @param {string} level
1958
+ * @param {string} raw
1959
+ * @param {any} slugger
1960
+ */
1909
1961
  heading(text, level, raw, slugger) {
1910
1962
  if (this.options.headerIds) {
1911
- return '<h'
1912
- + level
1913
- + ' id="'
1914
- + this.options.headerPrefix
1915
- + slugger.slug(raw)
1916
- + '">'
1917
- + text
1918
- + '</h'
1919
- + level
1920
- + '>\n';
1963
+ const id = this.options.headerPrefix + slugger.slug(raw);
1964
+ return `<h${level} id="${id}">${text}</h${level}>\n`;
1921
1965
  }
1966
+
1922
1967
  // ignore IDs
1923
- return '<h' + level + '>' + text + '</h' + level + '>\n';
1968
+ return `<h${level}>${text}</h${level}>\n`;
1924
1969
  }
1925
1970
 
1926
1971
  hr() {
@@ -1933,8 +1978,11 @@ class Renderer {
1933
1978
  return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
1934
1979
  }
1935
1980
 
1981
+ /**
1982
+ * @param {string} text
1983
+ */
1936
1984
  listitem(text) {
1937
- return '<li>' + text + '</li>\n';
1985
+ return `<li>${text}</li>\n`;
1938
1986
  }
1939
1987
 
1940
1988
  checkbox(checked) {
@@ -1945,12 +1993,19 @@ class Renderer {
1945
1993
  + '> ';
1946
1994
  }
1947
1995
 
1996
+ /**
1997
+ * @param {string} text
1998
+ */
1948
1999
  paragraph(text) {
1949
- return '<p>' + text + '</p>\n';
2000
+ return `<p>${text}</p>\n`;
1950
2001
  }
1951
2002
 
2003
+ /**
2004
+ * @param {string} header
2005
+ * @param {string} body
2006
+ */
1952
2007
  table(header, body) {
1953
- if (body) body = '<tbody>' + body + '</tbody>';
2008
+ if (body) body = `<tbody>${body}</tbody>`;
1954
2009
 
1955
2010
  return '<table>\n'
1956
2011
  + '<thead>\n'
@@ -1960,39 +2015,59 @@ class Renderer {
1960
2015
  + '</table>\n';
1961
2016
  }
1962
2017
 
2018
+ /**
2019
+ * @param {string} content
2020
+ */
1963
2021
  tablerow(content) {
1964
- return '<tr>\n' + content + '</tr>\n';
2022
+ return `<tr>\n${content}</tr>\n`;
1965
2023
  }
1966
2024
 
1967
2025
  tablecell(content, flags) {
1968
2026
  const type = flags.header ? 'th' : 'td';
1969
2027
  const tag = flags.align
1970
- ? '<' + type + ' align="' + flags.align + '">'
1971
- : '<' + type + '>';
1972
- return tag + content + '</' + type + '>\n';
2028
+ ? `<${type} align="${flags.align}">`
2029
+ : `<${type}>`;
2030
+ return tag + content + `</${type}>\n`;
1973
2031
  }
1974
2032
 
1975
- // span level renderer
2033
+ /**
2034
+ * span level renderer
2035
+ * @param {string} text
2036
+ */
1976
2037
  strong(text) {
1977
- return '<strong>' + text + '</strong>';
2038
+ return `<strong>${text}</strong>`;
1978
2039
  }
1979
2040
 
2041
+ /**
2042
+ * @param {string} text
2043
+ */
1980
2044
  em(text) {
1981
- return '<em>' + text + '</em>';
2045
+ return `<em>${text}</em>`;
1982
2046
  }
1983
2047
 
2048
+ /**
2049
+ * @param {string} text
2050
+ */
1984
2051
  codespan(text) {
1985
- return '<code>' + text + '</code>';
2052
+ return `<code>${text}</code>`;
1986
2053
  }
1987
2054
 
1988
2055
  br() {
1989
2056
  return this.options.xhtml ? '<br/>' : '<br>';
1990
2057
  }
1991
2058
 
2059
+ /**
2060
+ * @param {string} text
2061
+ */
1992
2062
  del(text) {
1993
- return '<del>' + text + '</del>';
2063
+ return `<del>${text}</del>`;
1994
2064
  }
1995
2065
 
2066
+ /**
2067
+ * @param {string} href
2068
+ * @param {string} title
2069
+ * @param {string} text
2070
+ */
1996
2071
  link(href, title, text) {
1997
2072
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
1998
2073
  if (href === null) {
@@ -2006,15 +2081,20 @@ class Renderer {
2006
2081
  return out;
2007
2082
  }
2008
2083
 
2084
+ /**
2085
+ * @param {string} href
2086
+ * @param {string} title
2087
+ * @param {string} text
2088
+ */
2009
2089
  image(href, title, text) {
2010
2090
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2011
2091
  if (href === null) {
2012
2092
  return text;
2013
2093
  }
2014
2094
 
2015
- let out = '<img src="' + href + '" alt="' + text + '"';
2095
+ let out = `<img src="${href}" alt="${text}"`;
2016
2096
  if (title) {
2017
- out += ' title="' + title + '"';
2097
+ out += ` title="${title}"`;
2018
2098
  }
2019
2099
  out += this.options.xhtml ? '/>' : '>';
2020
2100
  return out;
@@ -2076,6 +2156,9 @@ class Slugger {
2076
2156
  this.seen = {};
2077
2157
  }
2078
2158
 
2159
+ /**
2160
+ * @param {string} value
2161
+ */
2079
2162
  serialize(value) {
2080
2163
  return value
2081
2164
  .toLowerCase()
@@ -2089,6 +2172,8 @@ class Slugger {
2089
2172
 
2090
2173
  /**
2091
2174
  * Finds the next safe (unique) slug to use
2175
+ * @param {string} originalSlug
2176
+ * @param {boolean} isDryRun
2092
2177
  */
2093
2178
  getNextSafeSlug(originalSlug, isDryRun) {
2094
2179
  let slug = originalSlug;
@@ -2109,8 +2194,9 @@ class Slugger {
2109
2194
 
2110
2195
  /**
2111
2196
  * Convert string to unique id
2112
- * @param {object} options
2113
- * @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
2197
+ * @param {object} [options]
2198
+ * @param {boolean} [options.dryrun] Generates the next unique slug without
2199
+ * updating the internal accumulator.
2114
2200
  */
2115
2201
  slug(value, options = {}) {
2116
2202
  const slug = this.serialize(value);
@@ -2487,13 +2573,7 @@ function marked(src, opt, callback) {
2487
2573
  return;
2488
2574
  }
2489
2575
 
2490
- try {
2491
- const tokens = Lexer.lex(src, opt);
2492
- if (opt.walkTokens) {
2493
- marked.walkTokens(tokens, opt.walkTokens);
2494
- }
2495
- return Parser.parse(tokens, opt);
2496
- } catch (e) {
2576
+ function onError(e) {
2497
2577
  e.message += '\nPlease report this to https://github.com/markedjs/marked.';
2498
2578
  if (opt.silent) {
2499
2579
  return '<p>An error occurred:</p><pre>'
@@ -2502,6 +2582,23 @@ function marked(src, opt, callback) {
2502
2582
  }
2503
2583
  throw e;
2504
2584
  }
2585
+
2586
+ try {
2587
+ const tokens = Lexer.lex(src, opt);
2588
+ if (opt.walkTokens) {
2589
+ if (opt.async) {
2590
+ return Promise.all(marked.walkTokens(tokens, opt.walkTokens))
2591
+ .then(() => {
2592
+ return Parser.parse(tokens, opt);
2593
+ })
2594
+ .catch(onError);
2595
+ }
2596
+ marked.walkTokens(tokens, opt.walkTokens);
2597
+ }
2598
+ return Parser.parse(tokens, opt);
2599
+ } catch (e) {
2600
+ onError(e);
2601
+ }
2505
2602
  }
2506
2603
 
2507
2604
  /**
@@ -2618,10 +2715,12 @@ marked.use = function(...args) {
2618
2715
  if (pack.walkTokens) {
2619
2716
  const walkTokens = marked.defaults.walkTokens;
2620
2717
  opts.walkTokens = function(token) {
2621
- pack.walkTokens.call(this, token);
2718
+ let values = [];
2719
+ values.push(pack.walkTokens.call(this, token));
2622
2720
  if (walkTokens) {
2623
- walkTokens.call(this, token);
2721
+ values = values.concat(walkTokens.call(this, token));
2624
2722
  }
2723
+ return values;
2625
2724
  };
2626
2725
  }
2627
2726
 
@@ -2638,39 +2737,42 @@ marked.use = function(...args) {
2638
2737
  */
2639
2738
 
2640
2739
  marked.walkTokens = function(tokens, callback) {
2740
+ let values = [];
2641
2741
  for (const token of tokens) {
2642
- callback.call(marked, token);
2742
+ values = values.concat(callback.call(marked, token));
2643
2743
  switch (token.type) {
2644
2744
  case 'table': {
2645
2745
  for (const cell of token.header) {
2646
- marked.walkTokens(cell.tokens, callback);
2746
+ values = values.concat(marked.walkTokens(cell.tokens, callback));
2647
2747
  }
2648
2748
  for (const row of token.rows) {
2649
2749
  for (const cell of row) {
2650
- marked.walkTokens(cell.tokens, callback);
2750
+ values = values.concat(marked.walkTokens(cell.tokens, callback));
2651
2751
  }
2652
2752
  }
2653
2753
  break;
2654
2754
  }
2655
2755
  case 'list': {
2656
- marked.walkTokens(token.items, callback);
2756
+ values = values.concat(marked.walkTokens(token.items, callback));
2657
2757
  break;
2658
2758
  }
2659
2759
  default: {
2660
2760
  if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
2661
2761
  marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
2662
- marked.walkTokens(token[childTokens], callback);
2762
+ values = values.concat(marked.walkTokens(token[childTokens], callback));
2663
2763
  });
2664
2764
  } else if (token.tokens) {
2665
- marked.walkTokens(token.tokens, callback);
2765
+ values = values.concat(marked.walkTokens(token.tokens, callback));
2666
2766
  }
2667
2767
  }
2668
2768
  }
2669
2769
  }
2770
+ return values;
2670
2771
  };
2671
2772
 
2672
2773
  /**
2673
2774
  * Parse Inline
2775
+ * @param {string} src
2674
2776
  */
2675
2777
  marked.parseInline = function(src, opt) {
2676
2778
  // throw error in case of non string input