marked 2.0.7 → 2.1.3

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.
package/lib/marked.js CHANGED
@@ -75,6 +75,7 @@
75
75
  return {
76
76
  baseUrl: null,
77
77
  breaks: false,
78
+ extensions: null,
78
79
  gfm: true,
79
80
  headerIds: true,
80
81
  headerPrefix: '',
@@ -1165,14 +1166,14 @@
1165
1166
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
1166
1167
  list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\n*|\s*$)/,
1167
1168
  html: '^ {0,3}(?:' // optional indentation
1168
- + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
1169
+ + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
1169
1170
  + '|comment[^\\n]*(\\n+|$)' // (2)
1170
1171
  + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
1171
1172
  + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
1172
1173
  + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
1173
1174
  + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
1174
- + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
1175
- + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
1175
+ + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
1176
+ + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
1176
1177
  + ')',
1177
1178
  def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
1178
1179
  nptable: noopTest,
@@ -1196,7 +1197,7 @@
1196
1197
  block$1.html = edit(block$1.html, 'i').replace('comment', block$1._comment).replace('tag', block$1._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
1197
1198
  block$1.paragraph = edit(block$1._paragraph).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
1198
1199
  .replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1199
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block$1._tag) // pars can be interrupted by type (6) html blocks
1200
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block$1._tag) // pars can be interrupted by type (6) html blocks
1200
1201
  .getRegex();
1201
1202
  block$1.blockquote = edit(block$1.blockquote).replace('paragraph', block$1.paragraph).getRegex();
1202
1203
  /**
@@ -1219,10 +1220,10 @@
1219
1220
 
1220
1221
  });
1221
1222
  block$1.gfm.nptable = edit(block$1.gfm.nptable).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1222
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
1223
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
1223
1224
  .getRegex();
1224
1225
  block$1.gfm.table = edit(block$1.gfm.table).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
1225
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
1226
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
1226
1227
  .getRegex();
1227
1228
  /**
1228
1229
  * Pedantic grammar (original John Gruber's loose markdown specification)
@@ -1458,6 +1459,8 @@
1458
1459
  ;
1459
1460
 
1460
1461
  _proto.blockTokens = function blockTokens(src, tokens, top) {
1462
+ var _this = this;
1463
+
1461
1464
  if (tokens === void 0) {
1462
1465
  tokens = [];
1463
1466
  }
@@ -1470,10 +1473,22 @@
1470
1473
  src = src.replace(/^ +$/gm, '');
1471
1474
  }
1472
1475
 
1473
- var token, i, l, lastToken;
1476
+ var token, i, l, lastToken, cutSrc, lastParagraphClipped;
1474
1477
 
1475
1478
  while (src) {
1476
- // newline
1479
+ if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(function (extTokenizer) {
1480
+ if (token = extTokenizer.call(_this, src, tokens)) {
1481
+ src = src.substring(token.raw.length);
1482
+ tokens.push(token);
1483
+ return true;
1484
+ }
1485
+
1486
+ return false;
1487
+ })) {
1488
+ continue;
1489
+ } // newline
1490
+
1491
+
1477
1492
  if (token = this.tokenizer.space(src)) {
1478
1493
  src = src.substring(token.raw.length);
1479
1494
 
@@ -1582,11 +1597,43 @@
1582
1597
  tokens.push(token);
1583
1598
  continue;
1584
1599
  } // top-level paragraph
1600
+ // prevent paragraph consuming extensions by clipping 'src' to extension start
1601
+
1602
+
1603
+ cutSrc = src;
1604
+
1605
+ if (this.options.extensions && this.options.extensions.startBlock) {
1606
+ (function () {
1607
+ var startIndex = Infinity;
1608
+ var tempSrc = src.slice(1);
1609
+ var tempStart = void 0;
1610
+
1611
+ _this.options.extensions.startBlock.forEach(function (getStartIndex) {
1612
+ tempStart = getStartIndex.call(this, tempSrc);
1613
+
1614
+ if (typeof tempStart === 'number' && tempStart >= 0) {
1615
+ startIndex = Math.min(startIndex, tempStart);
1616
+ }
1617
+ });
1618
+
1619
+ if (startIndex < Infinity && startIndex >= 0) {
1620
+ cutSrc = src.substring(0, startIndex + 1);
1621
+ }
1622
+ })();
1623
+ }
1585
1624
 
1625
+ if (top && (token = this.tokenizer.paragraph(cutSrc))) {
1626
+ lastToken = tokens[tokens.length - 1];
1586
1627
 
1587
- if (top && (token = this.tokenizer.paragraph(src))) {
1628
+ if (lastParagraphClipped && lastToken.type === 'paragraph') {
1629
+ lastToken.raw += '\n' + token.raw;
1630
+ lastToken.text += '\n' + token.text;
1631
+ } else {
1632
+ tokens.push(token);
1633
+ }
1634
+
1635
+ lastParagraphClipped = cutSrc.length !== src.length;
1588
1636
  src = src.substring(token.raw.length);
1589
- tokens.push(token);
1590
1637
  continue;
1591
1638
  } // text
1592
1639
 
@@ -1694,6 +1741,8 @@
1694
1741
  ;
1695
1742
 
1696
1743
  _proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock) {
1744
+ var _this2 = this;
1745
+
1697
1746
  if (tokens === void 0) {
1698
1747
  tokens = [];
1699
1748
  }
@@ -1706,7 +1755,7 @@
1706
1755
  inRawBlock = false;
1707
1756
  }
1708
1757
 
1709
- var token, lastToken; // String with links masked to avoid interference with em and strong
1758
+ var token, lastToken, cutSrc; // String with links masked to avoid interference with em and strong
1710
1759
 
1711
1760
  var maskedSrc = src;
1712
1761
  var match;
@@ -1739,7 +1788,20 @@
1739
1788
  prevChar = '';
1740
1789
  }
1741
1790
 
1742
- keepPrevChar = false; // escape
1791
+ keepPrevChar = false; // extensions
1792
+
1793
+ if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(function (extTokenizer) {
1794
+ if (token = extTokenizer.call(_this2, src, tokens)) {
1795
+ src = src.substring(token.raw.length);
1796
+ tokens.push(token);
1797
+ return true;
1798
+ }
1799
+
1800
+ return false;
1801
+ })) {
1802
+ continue;
1803
+ } // escape
1804
+
1743
1805
 
1744
1806
  if (token = this.tokenizer.escape(src)) {
1745
1807
  src = src.substring(token.raw.length);
@@ -1752,11 +1814,11 @@
1752
1814
  src = src.substring(token.raw.length);
1753
1815
  inLink = token.inLink;
1754
1816
  inRawBlock = token.inRawBlock;
1755
- var _lastToken = tokens[tokens.length - 1];
1817
+ lastToken = tokens[tokens.length - 1];
1756
1818
 
1757
- if (_lastToken && token.type === 'text' && _lastToken.type === 'text') {
1758
- _lastToken.raw += token.raw;
1759
- _lastToken.text += token.text;
1819
+ if (lastToken && token.type === 'text' && lastToken.type === 'text') {
1820
+ lastToken.raw += token.raw;
1821
+ lastToken.text += token.text;
1760
1822
  } else {
1761
1823
  tokens.push(token);
1762
1824
  }
@@ -1779,14 +1841,14 @@
1779
1841
 
1780
1842
  if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1781
1843
  src = src.substring(token.raw.length);
1782
- var _lastToken2 = tokens[tokens.length - 1];
1844
+ lastToken = tokens[tokens.length - 1];
1783
1845
 
1784
1846
  if (token.type === 'link') {
1785
1847
  token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
1786
1848
  tokens.push(token);
1787
- } else if (_lastToken2 && token.type === 'text' && _lastToken2.type === 'text') {
1788
- _lastToken2.raw += token.raw;
1789
- _lastToken2.text += token.text;
1849
+ } else if (lastToken && token.type === 'text' && lastToken.type === 'text') {
1850
+ lastToken.raw += token.raw;
1851
+ lastToken.text += token.text;
1790
1852
  } else {
1791
1853
  tokens.push(token);
1792
1854
  }
@@ -1837,9 +1899,32 @@
1837
1899
  tokens.push(token);
1838
1900
  continue;
1839
1901
  } // text
1902
+ // prevent inlineText consuming extensions by clipping 'src' to extension start
1840
1903
 
1841
1904
 
1842
- if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
1905
+ cutSrc = src;
1906
+
1907
+ if (this.options.extensions && this.options.extensions.startInline) {
1908
+ (function () {
1909
+ var startIndex = Infinity;
1910
+ var tempSrc = src.slice(1);
1911
+ var tempStart = void 0;
1912
+
1913
+ _this2.options.extensions.startInline.forEach(function (getStartIndex) {
1914
+ tempStart = getStartIndex.call(this, tempSrc);
1915
+
1916
+ if (typeof tempStart === 'number' && tempStart >= 0) {
1917
+ startIndex = Math.min(startIndex, tempStart);
1918
+ }
1919
+ });
1920
+
1921
+ if (startIndex < Infinity && startIndex >= 0) {
1922
+ cutSrc = src.substring(0, startIndex + 1);
1923
+ }
1924
+ })();
1925
+ }
1926
+
1927
+ if (token = this.tokenizer.inlineText(cutSrc, inRawBlock, smartypants)) {
1843
1928
  src = src.substring(token.raw.length);
1844
1929
 
1845
1930
  if (token.raw.slice(-1) !== '_') {
@@ -2215,11 +2300,21 @@
2215
2300
  item,
2216
2301
  checked,
2217
2302
  task,
2218
- checkbox;
2303
+ checkbox,
2304
+ ret;
2219
2305
  var l = tokens.length;
2220
2306
 
2221
2307
  for (i = 0; i < l; i++) {
2222
- token = tokens[i];
2308
+ token = tokens[i]; // Run any renderer extensions
2309
+
2310
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2311
+ ret = this.options.extensions.renderers[token.type].call(this, token);
2312
+
2313
+ if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
2314
+ out += ret || '';
2315
+ continue;
2316
+ }
2317
+ }
2223
2318
 
2224
2319
  switch (token.type) {
2225
2320
  case 'space':
@@ -2383,11 +2478,21 @@
2383
2478
  renderer = renderer || this.renderer;
2384
2479
  var out = '',
2385
2480
  i,
2386
- token;
2481
+ token,
2482
+ ret;
2387
2483
  var l = tokens.length;
2388
2484
 
2389
2485
  for (i = 0; i < l; i++) {
2390
- token = tokens[i];
2486
+ token = tokens[i]; // Run any renderer extensions
2487
+
2488
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
2489
+ ret = this.options.extensions.renderers[token.type].call(this, token);
2490
+
2491
+ if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
2492
+ out += ret || '';
2493
+ continue;
2494
+ }
2495
+ }
2391
2496
 
2392
2497
  switch (token.type) {
2393
2498
  case 'escape':
@@ -2606,82 +2711,169 @@
2606
2711
  * Use Extension
2607
2712
  */
2608
2713
 
2609
- marked.use = function (extension) {
2610
- var opts = merge({}, extension);
2714
+ marked.use = function () {
2715
+ var _this = this;
2716
+
2717
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2718
+ args[_key] = arguments[_key];
2719
+ }
2720
+
2721
+ var opts = merge.apply(void 0, [{}].concat(args));
2722
+ var extensions = marked.defaults.extensions || {
2723
+ renderers: {},
2724
+ childTokens: {}
2725
+ };
2726
+ var hasExtensions;
2727
+ args.forEach(function (pack) {
2728
+ // ==-- Parse "addon" extensions --== //
2729
+ if (pack.extensions) {
2730
+ hasExtensions = true;
2731
+ pack.extensions.forEach(function (ext) {
2732
+ if (!ext.name) {
2733
+ throw new Error('extension name required');
2734
+ }
2611
2735
 
2612
- if (extension.renderer) {
2613
- (function () {
2614
- var renderer = marked.defaults.renderer || new Renderer();
2736
+ if (ext.renderer) {
2737
+ // Renderer extensions
2738
+ var prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
2739
+
2740
+ if (prevRenderer) {
2741
+ // Replace extension with func to run new extension but fall back if false
2742
+ extensions.renderers[ext.name] = function () {
2743
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2744
+ args[_key2] = arguments[_key2];
2745
+ }
2615
2746
 
2616
- var _loop = function _loop(prop) {
2617
- var prevRenderer = renderer[prop];
2747
+ var ret = ext.renderer.apply(this, args);
2618
2748
 
2619
- renderer[prop] = function () {
2620
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2621
- args[_key] = arguments[_key];
2749
+ if (ret === false) {
2750
+ ret = prevRenderer.apply(this, args);
2751
+ }
2752
+
2753
+ return ret;
2754
+ };
2755
+ } else {
2756
+ extensions.renderers[ext.name] = ext.renderer;
2622
2757
  }
2758
+ }
2623
2759
 
2624
- var ret = extension.renderer[prop].apply(renderer, args);
2760
+ if (ext.tokenizer) {
2761
+ // Tokenizer Extensions
2762
+ if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
2763
+ throw new Error("extension level must be 'block' or 'inline'");
2764
+ }
2765
+
2766
+ if (extensions[ext.level]) {
2767
+ extensions[ext.level].unshift(ext.tokenizer);
2768
+ } else {
2769
+ extensions[ext.level] = [ext.tokenizer];
2770
+ }
2625
2771
 
2626
- if (ret === false) {
2627
- ret = prevRenderer.apply(renderer, args);
2772
+ if (ext.start) {
2773
+ // Function to check for start of token
2774
+ if (ext.level === 'block') {
2775
+ if (extensions.startBlock) {
2776
+ extensions.startBlock.push(ext.start);
2777
+ } else {
2778
+ extensions.startBlock = [ext.start];
2779
+ }
2780
+ } else if (ext.level === 'inline') {
2781
+ if (extensions.startInline) {
2782
+ extensions.startInline.push(ext.start);
2783
+ } else {
2784
+ extensions.startInline = [ext.start];
2785
+ }
2786
+ }
2628
2787
  }
2788
+ }
2789
+
2790
+ if (ext.childTokens) {
2791
+ // Child tokens to be visited by walkTokens
2792
+ extensions.childTokens[ext.name] = ext.childTokens;
2793
+ }
2794
+ });
2795
+ } // ==-- Parse "overwrite" extensions --== //
2796
+
2797
+
2798
+ if (pack.renderer) {
2799
+ (function () {
2800
+ var renderer = marked.defaults.renderer || new Renderer();
2801
+
2802
+ var _loop = function _loop(prop) {
2803
+ var prevRenderer = renderer[prop]; // Replace renderer with func to run extension, but fall back if false
2804
+
2805
+ renderer[prop] = function () {
2806
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2807
+ args[_key3] = arguments[_key3];
2808
+ }
2809
+
2810
+ var ret = pack.renderer[prop].apply(renderer, args);
2811
+
2812
+ if (ret === false) {
2813
+ ret = prevRenderer.apply(renderer, args);
2814
+ }
2629
2815
 
2630
- return ret;
2816
+ return ret;
2817
+ };
2631
2818
  };
2632
- };
2633
2819
 
2634
- for (var prop in extension.renderer) {
2635
- _loop(prop);
2636
- }
2820
+ for (var prop in pack.renderer) {
2821
+ _loop(prop);
2822
+ }
2637
2823
 
2638
- opts.renderer = renderer;
2639
- })();
2640
- }
2824
+ opts.renderer = renderer;
2825
+ })();
2826
+ }
2641
2827
 
2642
- if (extension.tokenizer) {
2643
- (function () {
2644
- var tokenizer = marked.defaults.tokenizer || new Tokenizer();
2828
+ if (pack.tokenizer) {
2829
+ (function () {
2830
+ var tokenizer = marked.defaults.tokenizer || new Tokenizer();
2645
2831
 
2646
- var _loop2 = function _loop2(prop) {
2647
- var prevTokenizer = tokenizer[prop];
2832
+ var _loop2 = function _loop2(prop) {
2833
+ var prevTokenizer = tokenizer[prop]; // Replace tokenizer with func to run extension, but fall back if false
2648
2834
 
2649
- tokenizer[prop] = function () {
2650
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2651
- args[_key2] = arguments[_key2];
2652
- }
2835
+ tokenizer[prop] = function () {
2836
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2837
+ args[_key4] = arguments[_key4];
2838
+ }
2653
2839
 
2654
- var ret = extension.tokenizer[prop].apply(tokenizer, args);
2840
+ var ret = pack.tokenizer[prop].apply(tokenizer, args);
2655
2841
 
2656
- if (ret === false) {
2657
- ret = prevTokenizer.apply(tokenizer, args);
2658
- }
2842
+ if (ret === false) {
2843
+ ret = prevTokenizer.apply(tokenizer, args);
2844
+ }
2659
2845
 
2660
- return ret;
2846
+ return ret;
2847
+ };
2661
2848
  };
2662
- };
2663
2849
 
2664
- for (var prop in extension.tokenizer) {
2665
- _loop2(prop);
2666
- }
2850
+ for (var prop in pack.tokenizer) {
2851
+ _loop2(prop);
2852
+ }
2667
2853
 
2668
- opts.tokenizer = tokenizer;
2669
- })();
2670
- }
2854
+ opts.tokenizer = tokenizer;
2855
+ })();
2856
+ } // ==-- Parse WalkTokens extensions --== //
2671
2857
 
2672
- if (extension.walkTokens) {
2673
- var walkTokens = marked.defaults.walkTokens;
2674
2858
 
2675
- opts.walkTokens = function (token) {
2676
- extension.walkTokens(token);
2859
+ if (pack.walkTokens) {
2860
+ var walkTokens = marked.defaults.walkTokens;
2677
2861
 
2678
- if (walkTokens) {
2679
- walkTokens(token);
2680
- }
2681
- };
2682
- }
2862
+ opts.walkTokens = function (token) {
2863
+ pack.walkTokens.call(_this, token);
2864
+
2865
+ if (walkTokens) {
2866
+ walkTokens(token);
2867
+ }
2868
+ };
2869
+ }
2683
2870
 
2684
- marked.setOptions(opts);
2871
+ if (hasExtensions) {
2872
+ opts.extensions = extensions;
2873
+ }
2874
+
2875
+ marked.setOptions(opts);
2876
+ });
2685
2877
  };
2686
2878
  /**
2687
2879
  * Run callback for every token
@@ -2689,7 +2881,7 @@
2689
2881
 
2690
2882
 
2691
2883
  marked.walkTokens = function (tokens, callback) {
2692
- for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
2884
+ var _loop3 = function _loop3() {
2693
2885
  var token = _step.value;
2694
2886
  callback(token);
2695
2887
 
@@ -2721,11 +2913,20 @@
2721
2913
 
2722
2914
  default:
2723
2915
  {
2724
- if (token.tokens) {
2916
+ if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) {
2917
+ // Walk any extensions
2918
+ marked.defaults.extensions.childTokens[token.type].forEach(function (childTokens) {
2919
+ marked.walkTokens(token[childTokens], callback);
2920
+ });
2921
+ } else if (token.tokens) {
2725
2922
  marked.walkTokens(token.tokens, callback);
2726
2923
  }
2727
2924
  }
2728
2925
  }
2926
+ };
2927
+
2928
+ for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
2929
+ _loop3();
2729
2930
  }
2730
2931
  };
2731
2932
  /**