@saasquatch/vanilla-components 1.4.2-1 → 1.4.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.
Files changed (29) hide show
  1. package/dist/cjs/{WidgetHost-7c65e2c5.js → WidgetHost-71b013eb.js} +2 -2
  2. package/dist/cjs/sqh-close-button.cjs.entry.js +1 -1
  3. package/dist/cjs/sqh-copy-button_12.cjs.entry.js +1537 -1287
  4. package/dist/cjs/sqh-referral-code.cjs.entry.js +1 -1
  5. package/dist/collection/components/text-component/text-component.js +4 -4
  6. package/dist/collection/services/WidgetHost.js +2 -2
  7. package/dist/collection/utilities.js +12 -1
  8. package/dist/esm/{WidgetHost-b09e0d27.js → WidgetHost-9c337319.js} +2 -2
  9. package/dist/esm/sqh-close-button.entry.js +1 -1
  10. package/dist/esm/sqh-copy-button_12.entry.js +1537 -1287
  11. package/dist/esm/sqh-referral-code.entry.js +1 -1
  12. package/dist/esm-es5/{WidgetHost-b09e0d27.js → WidgetHost-9c337319.js} +2 -2
  13. package/dist/esm-es5/sqh-close-button.entry.js +1 -1
  14. package/dist/esm-es5/sqh-copy-button_12.entry.js +1401 -828
  15. package/dist/esm-es5/sqh-referral-code.entry.js +1 -1
  16. package/dist/types/utilities.d.ts +10 -1
  17. package/dist/widget-components/{p-c1c81a3b.entry.js → p-366f1663.entry.js} +1 -1
  18. package/dist/widget-components/{p-d6bde96f.entry.js → p-54ea7a00.entry.js} +1 -1
  19. package/dist/widget-components/p-5829fc57.system.entry.js +8 -0
  20. package/dist/widget-components/p-58be1132.system.js +1 -1
  21. package/dist/widget-components/{p-37fd6e72.system.js → p-8e232564.system.js} +1 -1
  22. package/dist/widget-components/{p-1a19f961.system.entry.js → p-b17efca4.system.entry.js} +1 -1
  23. package/dist/widget-components/p-b9ae08a2.entry.js +149 -0
  24. package/dist/widget-components/{p-e1d2fd8f.system.entry.js → p-c8bc8c77.system.entry.js} +1 -1
  25. package/dist/widget-components/{p-5f2ae286.js → p-edd43dbc.js} +2 -2
  26. package/dist/widget-components/widget-components.esm.js +1 -1
  27. package/package.json +20 -29
  28. package/dist/widget-components/p-2e323fe9.system.entry.js +0 -8
  29. package/dist/widget-components/p-7c848114.entry.js +0 -149
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, c as createEvent, g as getElement } from './index-8ea8b6d8.js';
2
2
  import { c as createCommonjsModule, a as commonjsGlobal, u as unwrapExports } from './_commonjsHelpers-1d681858.js';
3
- import { A as API } from './WidgetHost-b09e0d27.js';
3
+ import { A as API } from './WidgetHost-9c337319.js';
4
4
 
5
5
  /////////////////////////////////////
6
6
  ////// ////
@@ -82,6 +82,17 @@ const uuid = function b(a = undefined) {
82
82
  ? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16)
83
83
  : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, b);
84
84
  };
85
+ /**
86
+ * Decides whether a background value should be treated as an image URL
87
+ * (as opposed to a CSS color). The check is anchored to the start of the
88
+ * value and runs in linear time: an unanchored pattern would rescan the
89
+ * remaining suffix at every word boundary, freezing the widget on long
90
+ * non-URL values (e.g. "a.".repeat(32000) + "!") since it runs
91
+ * synchronously in render(). Embedded URLs are intentionally unsupported.
92
+ */
93
+ const isUrl = (value) => {
94
+ return /^(?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|(?:\/\/)?(?:www\d{0,3}\.|[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,4}\/))/i.test(value.trim());
95
+ };
85
96
 
86
97
  /*
87
98
 
@@ -7520,7 +7531,7 @@ function lexer(str) {
7520
7531
  break;
7521
7532
  }
7522
7533
  if (!name)
7523
- throw new TypeError("Missing parameter name at " + i);
7534
+ throw new TypeError("Missing parameter name at ".concat(i));
7524
7535
  tokens.push({ type: "NAME", index: i, value: name });
7525
7536
  i = j;
7526
7537
  continue;
@@ -7530,7 +7541,7 @@ function lexer(str) {
7530
7541
  var pattern = "";
7531
7542
  var j = i + 1;
7532
7543
  if (str[j] === "?") {
7533
- throw new TypeError("Pattern cannot start with \"?\" at " + j);
7544
+ throw new TypeError("Pattern cannot start with \"?\" at ".concat(j));
7534
7545
  }
7535
7546
  while (j < str.length) {
7536
7547
  if (str[j] === "\\") {
@@ -7547,15 +7558,15 @@ function lexer(str) {
7547
7558
  else if (str[j] === "(") {
7548
7559
  count++;
7549
7560
  if (str[j + 1] !== "?") {
7550
- throw new TypeError("Capturing groups are not allowed at " + j);
7561
+ throw new TypeError("Capturing groups are not allowed at ".concat(j));
7551
7562
  }
7552
7563
  }
7553
7564
  pattern += str[j++];
7554
7565
  }
7555
7566
  if (count)
7556
- throw new TypeError("Unbalanced pattern at " + i);
7567
+ throw new TypeError("Unbalanced pattern at ".concat(i));
7557
7568
  if (!pattern)
7558
- throw new TypeError("Missing pattern at " + i);
7569
+ throw new TypeError("Missing pattern at ".concat(i));
7559
7570
  tokens.push({ type: "PATTERN", index: i, value: pattern });
7560
7571
  i = j;
7561
7572
  continue;
@@ -7571,8 +7582,7 @@ function lexer(str) {
7571
7582
  function parse$1(str, options) {
7572
7583
  if (options === void 0) { options = {}; }
7573
7584
  var tokens = lexer(str);
7574
- var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
7575
- var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
7585
+ var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
7576
7586
  var result = [];
7577
7587
  var key = 0;
7578
7588
  var i = 0;
@@ -7586,17 +7596,34 @@ function parse$1(str, options) {
7586
7596
  if (value !== undefined)
7587
7597
  return value;
7588
7598
  var _a = tokens[i], nextType = _a.type, index = _a.index;
7589
- throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
7599
+ throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
7590
7600
  };
7591
7601
  var consumeText = function () {
7592
7602
  var result = "";
7593
7603
  var value;
7594
- // tslint:disable-next-line
7595
7604
  while ((value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR"))) {
7596
7605
  result += value;
7597
7606
  }
7598
7607
  return result;
7599
7608
  };
7609
+ var isSafe = function (value) {
7610
+ for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
7611
+ var char = delimiter_1[_i];
7612
+ if (value.indexOf(char) > -1)
7613
+ return true;
7614
+ }
7615
+ return false;
7616
+ };
7617
+ var safePattern = function (prefix) {
7618
+ var prev = result[result.length - 1];
7619
+ var prevText = prefix || (prev && typeof prev === "string" ? prev : "");
7620
+ if (prev && !prevText) {
7621
+ throw new TypeError("Must have text between two parameters, missing text after \"".concat(prev.name, "\""));
7622
+ }
7623
+ if (!prevText || isSafe(prevText))
7624
+ return "[^".concat(escapeString(delimiter), "]+?");
7625
+ return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
7626
+ };
7600
7627
  while (i < tokens.length) {
7601
7628
  var char = tryConsume("CHAR");
7602
7629
  var name = tryConsume("NAME");
@@ -7615,8 +7642,8 @@ function parse$1(str, options) {
7615
7642
  name: name || key++,
7616
7643
  prefix: prefix,
7617
7644
  suffix: "",
7618
- pattern: pattern || defaultPattern,
7619
- modifier: tryConsume("MODIFIER") || ""
7645
+ pattern: pattern || safePattern(prefix),
7646
+ modifier: tryConsume("MODIFIER") || "",
7620
7647
  });
7621
7648
  continue;
7622
7649
  }
@@ -7638,10 +7665,10 @@ function parse$1(str, options) {
7638
7665
  mustConsume("CLOSE");
7639
7666
  result.push({
7640
7667
  name: name_1 || (pattern_1 ? key++ : ""),
7641
- pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
7668
+ pattern: name_1 && !pattern_1 ? safePattern(prefix) : pattern_1,
7642
7669
  prefix: prefix,
7643
7670
  suffix: suffix,
7644
- modifier: tryConsume("MODIFIER") || ""
7671
+ modifier: tryConsume("MODIFIER") || "",
7645
7672
  });
7646
7673
  continue;
7647
7674
  }
@@ -7667,18 +7694,19 @@ function flags(options) {
7667
7694
  function regexpToRegexp(path, keys) {
7668
7695
  if (!keys)
7669
7696
  return path;
7670
- // Use a negative lookahead to match only capturing groups.
7671
- var groups = path.source.match(/\((?!\?)/g);
7672
- if (groups) {
7673
- for (var i = 0; i < groups.length; i++) {
7674
- keys.push({
7675
- name: i,
7676
- prefix: "",
7677
- suffix: "",
7678
- modifier: "",
7679
- pattern: ""
7680
- });
7681
- }
7697
+ var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
7698
+ var index = 0;
7699
+ var execResult = groupsRegex.exec(path.source);
7700
+ while (execResult) {
7701
+ keys.push({
7702
+ // Use parenthesized substring match if available, index otherwise
7703
+ name: execResult[1] || index++,
7704
+ prefix: "",
7705
+ suffix: "",
7706
+ modifier: "",
7707
+ pattern: "",
7708
+ });
7709
+ execResult = groupsRegex.exec(path.source);
7682
7710
  }
7683
7711
  return path;
7684
7712
  }
@@ -7687,7 +7715,7 @@ function regexpToRegexp(path, keys) {
7687
7715
  */
7688
7716
  function arrayToRegexp(paths, keys, options) {
7689
7717
  var parts = paths.map(function (path) { return pathToRegexp(path, keys, options).source; });
7690
- return new RegExp("(?:" + parts.join("|") + ")", flags(options));
7718
+ return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
7691
7719
  }
7692
7720
  /**
7693
7721
  * Create a path regexp from string input.
@@ -7700,9 +7728,9 @@ function stringToRegexp(path, keys, options) {
7700
7728
  */
7701
7729
  function tokensToRegexp(tokens, keys, options) {
7702
7730
  if (options === void 0) { options = {}; }
7703
- var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function (x) { return x; } : _d;
7704
- var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
7705
- var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
7731
+ var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function (x) { return x; } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
7732
+ var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
7733
+ var delimiterRe = "[".concat(escapeString(delimiter), "]");
7706
7734
  var route = start ? "^" : "";
7707
7735
  // Iterate over the tokens and create our regexp string.
7708
7736
  for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
@@ -7719,37 +7747,39 @@ function tokensToRegexp(tokens, keys, options) {
7719
7747
  if (prefix || suffix) {
7720
7748
  if (token.modifier === "+" || token.modifier === "*") {
7721
7749
  var mod = token.modifier === "*" ? "?" : "";
7722
- route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
7750
+ route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
7723
7751
  }
7724
7752
  else {
7725
- route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
7753
+ route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
7726
7754
  }
7727
7755
  }
7728
7756
  else {
7729
- route += "(" + token.pattern + ")" + token.modifier;
7757
+ if (token.modifier === "+" || token.modifier === "*") {
7758
+ throw new TypeError("Can not repeat \"".concat(token.name, "\" without a prefix and suffix"));
7759
+ }
7760
+ route += "(".concat(token.pattern, ")").concat(token.modifier);
7730
7761
  }
7731
7762
  }
7732
7763
  else {
7733
- route += "(?:" + prefix + suffix + ")" + token.modifier;
7764
+ route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
7734
7765
  }
7735
7766
  }
7736
7767
  }
7737
7768
  if (end) {
7738
7769
  if (!strict)
7739
- route += delimiter + "?";
7740
- route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
7770
+ route += "".concat(delimiterRe, "?");
7771
+ route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
7741
7772
  }
7742
7773
  else {
7743
7774
  var endToken = tokens[tokens.length - 1];
7744
7775
  var isEndDelimited = typeof endToken === "string"
7745
- ? delimiter.indexOf(endToken[endToken.length - 1]) > -1
7746
- : // tslint:disable-next-line
7747
- endToken === undefined;
7776
+ ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1
7777
+ : endToken === undefined;
7748
7778
  if (!strict) {
7749
- route += "(?:" + delimiter + "(?=" + endsWith + "))?";
7779
+ route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
7750
7780
  }
7751
7781
  if (!isEndDelimited) {
7752
- route += "(?=" + delimiter + "|" + endsWith + ")";
7782
+ route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
7753
7783
  }
7754
7784
  }
7755
7785
  return new RegExp(route, flags(options));
@@ -7875,10 +7905,10 @@ const StatsContainer = class {
7875
7905
  };
7876
7906
  StatsContainer.style = statsContainerCss;
7877
7907
 
7878
- var marked = createCommonjsModule(function (module, exports) {
7908
+ var marked_umd = createCommonjsModule(function (module, exports) {
7879
7909
  /**
7880
- * marked - a markdown parser
7881
- * Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
7910
+ * marked v4.3.0 - a markdown parser
7911
+ * Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
7882
7912
  * https://github.com/markedjs/marked
7883
7913
  */
7884
7914
 
@@ -7888,24 +7918,39 @@ var marked = createCommonjsModule(function (module, exports) {
7888
7918
  */
7889
7919
 
7890
7920
  (function (global, factory) {
7891
- module.exports = factory() ;
7892
- }(commonjsGlobal, (function () {
7921
+ factory(exports) ;
7922
+ })(commonjsGlobal, (function (exports) {
7893
7923
  function _defineProperties(target, props) {
7894
7924
  for (var i = 0; i < props.length; i++) {
7895
7925
  var descriptor = props[i];
7896
7926
  descriptor.enumerable = descriptor.enumerable || false;
7897
7927
  descriptor.configurable = true;
7898
7928
  if ("value" in descriptor) descriptor.writable = true;
7899
- Object.defineProperty(target, descriptor.key, descriptor);
7929
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
7900
7930
  }
7901
7931
  }
7902
-
7903
7932
  function _createClass(Constructor, protoProps, staticProps) {
7904
7933
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
7905
7934
  if (staticProps) _defineProperties(Constructor, staticProps);
7935
+ Object.defineProperty(Constructor, "prototype", {
7936
+ writable: false
7937
+ });
7906
7938
  return Constructor;
7907
7939
  }
7908
-
7940
+ function _extends() {
7941
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
7942
+ for (var i = 1; i < arguments.length; i++) {
7943
+ var source = arguments[i];
7944
+ for (var key in source) {
7945
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7946
+ target[key] = source[key];
7947
+ }
7948
+ }
7949
+ }
7950
+ return target;
7951
+ };
7952
+ return _extends.apply(this, arguments);
7953
+ }
7909
7954
  function _unsupportedIterableToArray(o, minLen) {
7910
7955
  if (!o) return;
7911
7956
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -7914,86 +7959,80 @@ var marked = createCommonjsModule(function (module, exports) {
7914
7959
  if (n === "Map" || n === "Set") return Array.from(o);
7915
7960
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
7916
7961
  }
7917
-
7918
7962
  function _arrayLikeToArray(arr, len) {
7919
7963
  if (len == null || len > arr.length) len = arr.length;
7920
-
7921
7964
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
7922
-
7923
7965
  return arr2;
7924
7966
  }
7925
-
7926
7967
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
7927
- var it;
7928
-
7929
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
7930
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
7931
- if (it) o = it;
7932
- var i = 0;
7933
- return function () {
7934
- if (i >= o.length) return {
7935
- done: true
7936
- };
7937
- return {
7938
- done: false,
7939
- value: o[i++]
7940
- };
7968
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
7969
+ if (it) return (it = it.call(o)).next.bind(it);
7970
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
7971
+ if (it) o = it;
7972
+ var i = 0;
7973
+ return function () {
7974
+ if (i >= o.length) return {
7975
+ done: true
7941
7976
  };
7942
- }
7943
-
7944
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7977
+ return {
7978
+ done: false,
7979
+ value: o[i++]
7980
+ };
7981
+ };
7945
7982
  }
7946
-
7947
- it = o[Symbol.iterator]();
7948
- return it.next.bind(it);
7983
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7949
7984
  }
7950
-
7951
- function createCommonjsModule(fn, module) {
7952
- return module = { exports: {} }, fn(module, module.exports), module.exports;
7985
+ function _toPrimitive(input, hint) {
7986
+ if (typeof input !== "object" || input === null) return input;
7987
+ var prim = input[Symbol.toPrimitive];
7988
+ if (prim !== undefined) {
7989
+ var res = prim.call(input, hint || "default");
7990
+ if (typeof res !== "object") return res;
7991
+ throw new TypeError("@@toPrimitive must return a primitive value.");
7992
+ }
7993
+ return (hint === "string" ? String : Number)(input);
7994
+ }
7995
+ function _toPropertyKey(arg) {
7996
+ var key = _toPrimitive(arg, "string");
7997
+ return typeof key === "symbol" ? key : String(key);
7953
7998
  }
7954
7999
 
7955
- var defaults = createCommonjsModule(function (module) {
7956
- function getDefaults() {
7957
- return {
7958
- baseUrl: null,
7959
- breaks: false,
7960
- gfm: true,
7961
- headerIds: true,
7962
- headerPrefix: '',
7963
- highlight: null,
7964
- langPrefix: 'language-',
7965
- mangle: true,
7966
- pedantic: false,
7967
- renderer: null,
7968
- sanitize: false,
7969
- sanitizer: null,
7970
- silent: false,
7971
- smartLists: false,
7972
- smartypants: false,
7973
- tokenizer: null,
7974
- walkTokens: null,
7975
- xhtml: false
7976
- };
7977
- }
7978
-
7979
- function changeDefaults(newDefaults) {
7980
- module.exports.defaults = newDefaults;
7981
- }
7982
-
7983
- module.exports = {
7984
- defaults: getDefaults(),
7985
- getDefaults: getDefaults,
7986
- changeDefaults: changeDefaults
8000
+ function getDefaults() {
8001
+ return {
8002
+ async: false,
8003
+ baseUrl: null,
8004
+ breaks: false,
8005
+ extensions: null,
8006
+ gfm: true,
8007
+ headerIds: true,
8008
+ headerPrefix: '',
8009
+ highlight: null,
8010
+ hooks: null,
8011
+ langPrefix: 'language-',
8012
+ mangle: true,
8013
+ pedantic: false,
8014
+ renderer: null,
8015
+ sanitize: false,
8016
+ sanitizer: null,
8017
+ silent: false,
8018
+ smartypants: false,
8019
+ tokenizer: null,
8020
+ walkTokens: null,
8021
+ xhtml: false
7987
8022
  };
7988
- });
8023
+ }
8024
+ exports.defaults = getDefaults();
8025
+ function changeDefaults(newDefaults) {
8026
+ exports.defaults = newDefaults;
8027
+ }
7989
8028
 
7990
8029
  /**
7991
8030
  * Helpers
7992
8031
  */
7993
8032
  var escapeTest = /[&<>"']/;
7994
- var escapeReplace = /[&<>"']/g;
7995
- var escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
7996
- var escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
8033
+ var escapeReplace = new RegExp(escapeTest.source, 'g');
8034
+ var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
8035
+ var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
7997
8036
  var escapeReplacements = {
7998
8037
  '&': '&amp;',
7999
8038
  '<': '&lt;',
@@ -8001,11 +8040,9 @@ var marked = createCommonjsModule(function (module, exports) {
8001
8040
  '"': '&quot;',
8002
8041
  "'": '&#39;'
8003
8042
  };
8004
-
8005
8043
  var getEscapeReplacement = function getEscapeReplacement(ch) {
8006
8044
  return escapeReplacements[ch];
8007
8045
  };
8008
-
8009
8046
  function escape(html, encode) {
8010
8047
  if (encode) {
8011
8048
  if (escapeTest.test(html)) {
@@ -8016,30 +8053,32 @@ var marked = createCommonjsModule(function (module, exports) {
8016
8053
  return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
8017
8054
  }
8018
8055
  }
8019
-
8020
8056
  return html;
8021
8057
  }
8022
-
8023
8058
  var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
8024
8059
 
8060
+ /**
8061
+ * @param {string} html
8062
+ */
8025
8063
  function unescape(html) {
8026
8064
  // explicitly match decimal, hex, and named HTML entities
8027
8065
  return html.replace(unescapeTest, function (_, n) {
8028
8066
  n = n.toLowerCase();
8029
8067
  if (n === 'colon') return ':';
8030
-
8031
8068
  if (n.charAt(0) === '#') {
8032
8069
  return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
8033
8070
  }
8034
-
8035
8071
  return '';
8036
8072
  });
8037
8073
  }
8038
-
8039
8074
  var caret = /(^|[^\[])\^/g;
8040
8075
 
8076
+ /**
8077
+ * @param {string | RegExp} regex
8078
+ * @param {string} opt
8079
+ */
8041
8080
  function edit(regex, opt) {
8042
- regex = regex.source || regex;
8081
+ regex = typeof regex === 'string' ? regex : regex.source;
8043
8082
  opt = opt || '';
8044
8083
  var obj = {
8045
8084
  replace: function replace(name, val) {
@@ -8054,43 +8093,45 @@ var marked = createCommonjsModule(function (module, exports) {
8054
8093
  };
8055
8094
  return obj;
8056
8095
  }
8057
-
8058
8096
  var nonWordAndColonTest = /[^\w:]/g;
8059
8097
  var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
8060
8098
 
8099
+ /**
8100
+ * @param {boolean} sanitize
8101
+ * @param {string} base
8102
+ * @param {string} href
8103
+ */
8061
8104
  function cleanUrl(sanitize, base, href) {
8062
8105
  if (sanitize) {
8063
8106
  var prot;
8064
-
8065
8107
  try {
8066
8108
  prot = decodeURIComponent(unescape(href)).replace(nonWordAndColonTest, '').toLowerCase();
8067
8109
  } catch (e) {
8068
8110
  return null;
8069
8111
  }
8070
-
8071
8112
  if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
8072
8113
  return null;
8073
8114
  }
8074
8115
  }
8075
-
8076
8116
  if (base && !originIndependentUrl.test(href)) {
8077
8117
  href = resolveUrl(base, href);
8078
8118
  }
8079
-
8080
8119
  try {
8081
8120
  href = encodeURI(href).replace(/%25/g, '%');
8082
8121
  } catch (e) {
8083
8122
  return null;
8084
8123
  }
8085
-
8086
8124
  return href;
8087
8125
  }
8088
-
8089
8126
  var baseUrls = {};
8090
8127
  var justDomain = /^[^:]+:\/*[^/]*$/;
8091
8128
  var protocol = /^([^:]+:)[\s\S]*$/;
8092
8129
  var domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
8093
8130
 
8131
+ /**
8132
+ * @param {string} base
8133
+ * @param {string} href
8134
+ */
8094
8135
  function resolveUrl(base, href) {
8095
8136
  if (!baseUrls[' ' + base]) {
8096
8137
  // we can ignore everything in base after the last slash of its path component,
@@ -8102,72 +8143,53 @@ var marked = createCommonjsModule(function (module, exports) {
8102
8143
  baseUrls[' ' + base] = rtrim(base, '/', true);
8103
8144
  }
8104
8145
  }
8105
-
8106
8146
  base = baseUrls[' ' + base];
8107
8147
  var relativeBase = base.indexOf(':') === -1;
8108
-
8109
8148
  if (href.substring(0, 2) === '//') {
8110
8149
  if (relativeBase) {
8111
8150
  return href;
8112
8151
  }
8113
-
8114
8152
  return base.replace(protocol, '$1') + href;
8115
8153
  } else if (href.charAt(0) === '/') {
8116
8154
  if (relativeBase) {
8117
8155
  return href;
8118
8156
  }
8119
-
8120
8157
  return base.replace(domain, '$1') + href;
8121
8158
  } else {
8122
8159
  return base + href;
8123
8160
  }
8124
8161
  }
8125
-
8126
8162
  var noopTest = {
8127
8163
  exec: function noopTest() {}
8128
8164
  };
8129
-
8130
- function merge(obj) {
8131
- var i = 1,
8132
- target,
8133
- key;
8134
-
8135
- for (; i < arguments.length; i++) {
8136
- target = arguments[i];
8137
-
8138
- for (key in target) {
8139
- if (Object.prototype.hasOwnProperty.call(target, key)) {
8140
- obj[key] = target[key];
8141
- }
8142
- }
8143
- }
8144
-
8145
- return obj;
8146
- }
8147
-
8148
8165
  function splitCells(tableRow, count) {
8149
8166
  // ensure that every cell-delimiting pipe has a space
8150
8167
  // before it to distinguish it from an escaped pipe
8151
8168
  var row = tableRow.replace(/\|/g, function (match, offset, str) {
8152
- var escaped = false,
8169
+ var escaped = false,
8153
8170
  curr = offset;
8154
-
8155
- while (--curr >= 0 && str[curr] === '\\') {
8156
- escaped = !escaped;
8157
- }
8158
-
8159
- if (escaped) {
8160
- // odd number of slashes means | is escaped
8161
- // so we leave it alone
8162
- return '|';
8163
- } else {
8164
- // add space before unescaped |
8165
- return ' |';
8166
- }
8167
- }),
8168
- cells = row.split(/ \|/);
8171
+ while (--curr >= 0 && str[curr] === '\\') {
8172
+ escaped = !escaped;
8173
+ }
8174
+ if (escaped) {
8175
+ // odd number of slashes means | is escaped
8176
+ // so we leave it alone
8177
+ return '|';
8178
+ } else {
8179
+ // add space before unescaped |
8180
+ return ' |';
8181
+ }
8182
+ }),
8183
+ cells = row.split(/ \|/);
8169
8184
  var i = 0;
8170
8185
 
8186
+ // First/last cell in a row cannot be empty if it has no leading/trailing pipe
8187
+ if (!cells[0].trim()) {
8188
+ cells.shift();
8189
+ }
8190
+ if (cells.length > 0 && !cells[cells.length - 1].trim()) {
8191
+ cells.pop();
8192
+ }
8171
8193
  if (cells.length > count) {
8172
8194
  cells.splice(count);
8173
8195
  } else {
@@ -8175,31 +8197,33 @@ var marked = createCommonjsModule(function (module, exports) {
8175
8197
  cells.push('');
8176
8198
  }
8177
8199
  }
8178
-
8179
8200
  for (; i < cells.length; i++) {
8180
8201
  // leading or trailing whitespace is ignored per the gfm spec
8181
8202
  cells[i] = cells[i].trim().replace(/\\\|/g, '|');
8182
8203
  }
8183
-
8184
8204
  return cells;
8185
- } // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
8186
- // /c*$/ is vulnerable to REDOS.
8187
- // invert: Remove suffix of non-c chars instead. Default falsey.
8188
-
8205
+ }
8189
8206
 
8207
+ /**
8208
+ * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
8209
+ * /c*$/ is vulnerable to REDOS.
8210
+ *
8211
+ * @param {string} str
8212
+ * @param {string} c
8213
+ * @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
8214
+ */
8190
8215
  function rtrim(str, c, invert) {
8191
8216
  var l = str.length;
8192
-
8193
8217
  if (l === 0) {
8194
8218
  return '';
8195
- } // Length of suffix matching the invert condition.
8196
-
8219
+ }
8197
8220
 
8198
- var suffLen = 0; // Step left until we fail to match the invert condition.
8221
+ // Length of suffix matching the invert condition.
8222
+ var suffLen = 0;
8199
8223
 
8224
+ // Step left until we fail to match the invert condition.
8200
8225
  while (suffLen < l) {
8201
8226
  var currChar = str.charAt(l - suffLen - 1);
8202
-
8203
8227
  if (currChar === c && !invert) {
8204
8228
  suffLen++;
8205
8229
  } else if (currChar !== c && invert) {
@@ -8208,19 +8232,15 @@ var marked = createCommonjsModule(function (module, exports) {
8208
8232
  break;
8209
8233
  }
8210
8234
  }
8211
-
8212
- return str.substr(0, l - suffLen);
8235
+ return str.slice(0, l - suffLen);
8213
8236
  }
8214
-
8215
8237
  function findClosingBracket(str, b) {
8216
8238
  if (str.indexOf(b[1]) === -1) {
8217
8239
  return -1;
8218
8240
  }
8219
-
8220
8241
  var l = str.length;
8221
8242
  var level = 0,
8222
- i = 0;
8223
-
8243
+ i = 0;
8224
8244
  for (; i < l; i++) {
8225
8245
  if (str[i] === '\\') {
8226
8246
  i++;
@@ -8228,212 +8248,151 @@ var marked = createCommonjsModule(function (module, exports) {
8228
8248
  level++;
8229
8249
  } else if (str[i] === b[1]) {
8230
8250
  level--;
8231
-
8232
8251
  if (level < 0) {
8233
8252
  return i;
8234
8253
  }
8235
8254
  }
8236
8255
  }
8237
-
8238
8256
  return -1;
8239
8257
  }
8240
-
8241
8258
  function checkSanitizeDeprecation(opt) {
8242
8259
  if (opt && opt.sanitize && !opt.silent) {
8243
8260
  console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
8244
8261
  }
8245
8262
  }
8246
8263
 
8247
- var helpers = {
8248
- escape: escape,
8249
- unescape: unescape,
8250
- edit: edit,
8251
- cleanUrl: cleanUrl,
8252
- resolveUrl: resolveUrl,
8253
- noopTest: noopTest,
8254
- merge: merge,
8255
- splitCells: splitCells,
8256
- rtrim: rtrim,
8257
- findClosingBracket: findClosingBracket,
8258
- checkSanitizeDeprecation: checkSanitizeDeprecation
8259
- };
8260
-
8261
- var defaults$1 = defaults.defaults;
8262
- var rtrim$1 = helpers.rtrim,
8263
- splitCells$1 = helpers.splitCells,
8264
- _escape = helpers.escape,
8265
- findClosingBracket$1 = helpers.findClosingBracket;
8264
+ // copied from https://stackoverflow.com/a/5450113/806777
8265
+ /**
8266
+ * @param {string} pattern
8267
+ * @param {number} count
8268
+ */
8269
+ function repeatString(pattern, count) {
8270
+ if (count < 1) {
8271
+ return '';
8272
+ }
8273
+ var result = '';
8274
+ while (count > 1) {
8275
+ if (count & 1) {
8276
+ result += pattern;
8277
+ }
8278
+ count >>= 1;
8279
+ pattern += pattern;
8280
+ }
8281
+ return result + pattern;
8282
+ }
8266
8283
 
8267
- function outputLink(cap, link, raw) {
8284
+ function outputLink(cap, link, raw, lexer) {
8268
8285
  var href = link.href;
8269
- var title = link.title ? _escape(link.title) : null;
8286
+ var title = link.title ? escape(link.title) : null;
8270
8287
  var text = cap[1].replace(/\\([\[\]])/g, '$1');
8271
-
8272
8288
  if (cap[0].charAt(0) !== '!') {
8273
- return {
8289
+ lexer.state.inLink = true;
8290
+ var token = {
8274
8291
  type: 'link',
8275
8292
  raw: raw,
8276
8293
  href: href,
8277
8294
  title: title,
8278
- text: text
8279
- };
8280
- } else {
8281
- return {
8282
- type: 'image',
8283
- raw: raw,
8284
- href: href,
8285
- title: title,
8286
- text: _escape(text)
8295
+ text: text,
8296
+ tokens: lexer.inlineTokens(text)
8287
8297
  };
8298
+ lexer.state.inLink = false;
8299
+ return token;
8288
8300
  }
8301
+ return {
8302
+ type: 'image',
8303
+ raw: raw,
8304
+ href: href,
8305
+ title: title,
8306
+ text: escape(text)
8307
+ };
8289
8308
  }
8290
-
8291
8309
  function indentCodeCompensation(raw, text) {
8292
8310
  var matchIndentToCode = raw.match(/^(\s+)(?:```)/);
8293
-
8294
8311
  if (matchIndentToCode === null) {
8295
8312
  return text;
8296
8313
  }
8297
-
8298
8314
  var indentToCode = matchIndentToCode[1];
8299
8315
  return text.split('\n').map(function (node) {
8300
8316
  var matchIndentInNode = node.match(/^\s+/);
8301
-
8302
8317
  if (matchIndentInNode === null) {
8303
8318
  return node;
8304
8319
  }
8305
-
8306
8320
  var indentInNode = matchIndentInNode[0];
8307
-
8308
8321
  if (indentInNode.length >= indentToCode.length) {
8309
8322
  return node.slice(indentToCode.length);
8310
8323
  }
8311
-
8312
8324
  return node;
8313
8325
  }).join('\n');
8314
8326
  }
8327
+
8315
8328
  /**
8316
8329
  * Tokenizer
8317
8330
  */
8318
-
8319
-
8320
- var Tokenizer_1 = /*#__PURE__*/function () {
8331
+ var Tokenizer = /*#__PURE__*/function () {
8321
8332
  function Tokenizer(options) {
8322
- this.options = options || defaults$1;
8333
+ this.options = options || exports.defaults;
8323
8334
  }
8324
-
8325
8335
  var _proto = Tokenizer.prototype;
8326
-
8327
8336
  _proto.space = function space(src) {
8328
8337
  var cap = this.rules.block.newline.exec(src);
8329
-
8330
- if (cap) {
8331
- if (cap[0].length > 1) {
8332
- return {
8333
- type: 'space',
8334
- raw: cap[0]
8335
- };
8336
- }
8337
-
8338
+ if (cap && cap[0].length > 0) {
8338
8339
  return {
8339
- raw: '\n'
8340
+ type: 'space',
8341
+ raw: cap[0]
8340
8342
  };
8341
8343
  }
8342
8344
  };
8343
-
8344
- _proto.code = function code(src, tokens) {
8345
+ _proto.code = function code(src) {
8345
8346
  var cap = this.rules.block.code.exec(src);
8346
-
8347
8347
  if (cap) {
8348
- var lastToken = tokens[tokens.length - 1]; // An indented code block cannot interrupt a paragraph.
8349
-
8350
- if (lastToken && lastToken.type === 'paragraph') {
8351
- return {
8352
- raw: cap[0],
8353
- text: cap[0].trimRight()
8354
- };
8355
- }
8356
-
8357
- var text = cap[0].replace(/^ {4}/gm, '');
8348
+ var text = cap[0].replace(/^ {1,4}/gm, '');
8358
8349
  return {
8359
8350
  type: 'code',
8360
8351
  raw: cap[0],
8361
8352
  codeBlockStyle: 'indented',
8362
- text: !this.options.pedantic ? rtrim$1(text, '\n') : text
8353
+ text: !this.options.pedantic ? rtrim(text, '\n') : text
8363
8354
  };
8364
8355
  }
8365
8356
  };
8366
-
8367
8357
  _proto.fences = function fences(src) {
8368
8358
  var cap = this.rules.block.fences.exec(src);
8369
-
8370
8359
  if (cap) {
8371
8360
  var raw = cap[0];
8372
8361
  var text = indentCodeCompensation(raw, cap[3] || '');
8373
8362
  return {
8374
8363
  type: 'code',
8375
8364
  raw: raw,
8376
- lang: cap[2] ? cap[2].trim() : cap[2],
8365
+ lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, '$1') : cap[2],
8377
8366
  text: text
8378
8367
  };
8379
8368
  }
8380
8369
  };
8381
-
8382
8370
  _proto.heading = function heading(src) {
8383
8371
  var cap = this.rules.block.heading.exec(src);
8384
-
8385
8372
  if (cap) {
8373
+ var text = cap[2].trim();
8374
+
8375
+ // remove trailing #s
8376
+ if (/#$/.test(text)) {
8377
+ var trimmed = rtrim(text, '#');
8378
+ if (this.options.pedantic) {
8379
+ text = trimmed.trim();
8380
+ } else if (!trimmed || / $/.test(trimmed)) {
8381
+ // CommonMark requires space before trailing #s
8382
+ text = trimmed.trim();
8383
+ }
8384
+ }
8386
8385
  return {
8387
8386
  type: 'heading',
8388
8387
  raw: cap[0],
8389
8388
  depth: cap[1].length,
8390
- text: cap[2]
8391
- };
8392
- }
8393
- };
8394
-
8395
- _proto.nptable = function nptable(src) {
8396
- var cap = this.rules.block.nptable.exec(src);
8397
-
8398
- if (cap) {
8399
- var item = {
8400
- type: 'table',
8401
- header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
8402
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
8403
- cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [],
8404
- raw: cap[0]
8389
+ text: text,
8390
+ tokens: this.lexer.inline(text)
8405
8391
  };
8406
-
8407
- if (item.header.length === item.align.length) {
8408
- var l = item.align.length;
8409
- var i;
8410
-
8411
- for (i = 0; i < l; i++) {
8412
- if (/^ *-+: *$/.test(item.align[i])) {
8413
- item.align[i] = 'right';
8414
- } else if (/^ *:-+: *$/.test(item.align[i])) {
8415
- item.align[i] = 'center';
8416
- } else if (/^ *:-+ *$/.test(item.align[i])) {
8417
- item.align[i] = 'left';
8418
- } else {
8419
- item.align[i] = null;
8420
- }
8421
- }
8422
-
8423
- l = item.cells.length;
8424
-
8425
- for (i = 0; i < l; i++) {
8426
- item.cells[i] = splitCells$1(item.cells[i], item.header.length);
8427
- }
8428
-
8429
- return item;
8430
- }
8431
8392
  }
8432
8393
  };
8433
-
8434
8394
  _proto.hr = function hr(src) {
8435
8395
  var cap = this.rules.block.hr.exec(src);
8436
-
8437
8396
  if (cap) {
8438
8397
  return {
8439
8398
  type: 'hr',
@@ -8441,155 +8400,254 @@ var marked = createCommonjsModule(function (module, exports) {
8441
8400
  };
8442
8401
  }
8443
8402
  };
8444
-
8445
8403
  _proto.blockquote = function blockquote(src) {
8446
8404
  var cap = this.rules.block.blockquote.exec(src);
8447
-
8448
8405
  if (cap) {
8449
- var text = cap[0].replace(/^ *> ?/gm, '');
8406
+ var text = cap[0].replace(/^ *>[ \t]?/gm, '');
8407
+ var top = this.lexer.state.top;
8408
+ this.lexer.state.top = true;
8409
+ var tokens = this.lexer.blockTokens(text);
8410
+ this.lexer.state.top = top;
8450
8411
  return {
8451
8412
  type: 'blockquote',
8452
8413
  raw: cap[0],
8414
+ tokens: tokens,
8453
8415
  text: text
8454
8416
  };
8455
8417
  }
8456
8418
  };
8457
-
8458
8419
  _proto.list = function list(src) {
8459
8420
  var cap = this.rules.block.list.exec(src);
8460
-
8461
8421
  if (cap) {
8462
- var raw = cap[0];
8463
- var bull = cap[2];
8422
+ var raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
8423
+ var bull = cap[1].trim();
8464
8424
  var isordered = bull.length > 1;
8465
- var isparen = bull[bull.length - 1] === ')';
8466
8425
  var list = {
8467
8426
  type: 'list',
8468
- raw: raw,
8427
+ raw: '',
8469
8428
  ordered: isordered,
8470
8429
  start: isordered ? +bull.slice(0, -1) : '',
8471
8430
  loose: false,
8472
8431
  items: []
8473
- }; // Get each top-level item.
8432
+ };
8433
+ bull = isordered ? "\\d{1,9}\\" + bull.slice(-1) : "\\" + bull;
8434
+ if (this.options.pedantic) {
8435
+ bull = isordered ? bull : '[*+-]';
8436
+ }
8474
8437
 
8475
- var itemMatch = cap[0].match(this.rules.block.item);
8476
- var next = false,
8477
- item,
8478
- space,
8479
- b,
8480
- addBack,
8481
- loose,
8482
- istask,
8483
- ischecked;
8484
- var l = itemMatch.length;
8438
+ // Get next list item
8439
+ var itemRegex = new RegExp("^( {0,3}" + bull + ")((?:[\t ][^\\n]*)?(?:\\n|$))");
8485
8440
 
8486
- for (var i = 0; i < l; i++) {
8487
- item = itemMatch[i];
8488
- raw = item; // Remove the list item's bullet
8489
- // so it is seen as the next token.
8441
+ // Check if current bullet point can start a new List Item
8442
+ while (src) {
8443
+ endEarly = false;
8444
+ if (!(cap = itemRegex.exec(src))) {
8445
+ break;
8446
+ }
8447
+ if (this.rules.block.hr.test(src)) {
8448
+ // End list if bullet was actually HR (possibly move into itemRegex?)
8449
+ break;
8450
+ }
8451
+ raw = cap[0];
8452
+ src = src.substring(raw.length);
8453
+ line = cap[2].split('\n', 1)[0].replace(/^\t+/, function (t) {
8454
+ return ' '.repeat(3 * t.length);
8455
+ });
8456
+ nextLine = src.split('\n', 1)[0];
8457
+ if (this.options.pedantic) {
8458
+ indent = 2;
8459
+ itemContents = line.trimLeft();
8460
+ } else {
8461
+ indent = cap[2].search(/[^ ]/); // Find first non-space char
8462
+ indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
8463
+ itemContents = line.slice(indent);
8464
+ indent += cap[1].length;
8465
+ }
8466
+ blankLine = false;
8467
+ if (!line && /^ *$/.test(nextLine)) {
8468
+ // Items begin with at most one blank line
8469
+ raw += nextLine + '\n';
8470
+ src = src.substring(nextLine.length + 1);
8471
+ endEarly = true;
8472
+ }
8473
+ if (!endEarly) {
8474
+ var nextBulletRegex = new RegExp("^ {0," + Math.min(3, indent - 1) + "}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))");
8475
+ var hrRegex = new RegExp("^ {0," + Math.min(3, indent - 1) + "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)");
8476
+ var fencesBeginRegex = new RegExp("^ {0," + Math.min(3, indent - 1) + "}(?:```|~~~)");
8477
+ var headingBeginRegex = new RegExp("^ {0," + Math.min(3, indent - 1) + "}#");
8478
+
8479
+ // Check if following lines should be included in List Item
8480
+ while (src) {
8481
+ rawLine = src.split('\n', 1)[0];
8482
+ nextLine = rawLine;
8483
+
8484
+ // Re-align to follow commonmark nesting rules
8485
+ if (this.options.pedantic) {
8486
+ nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
8487
+ }
8490
8488
 
8491
- space = item.length;
8492
- item = item.replace(/^ *([*+-]|\d+[.)]) */, ''); // Outdent whatever the
8493
- // list item contains. Hacky.
8489
+ // End list item if found code fences
8490
+ if (fencesBeginRegex.test(nextLine)) {
8491
+ break;
8492
+ }
8494
8493
 
8495
- if (~item.indexOf('\n ')) {
8496
- space -= item.length;
8497
- item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
8498
- } // Determine whether the next list item belongs here.
8499
- // Backpedal if it does not belong in this list.
8494
+ // End list item if found start of new heading
8495
+ if (headingBeginRegex.test(nextLine)) {
8496
+ break;
8497
+ }
8500
8498
 
8499
+ // End list item if found start of new bullet
8500
+ if (nextBulletRegex.test(nextLine)) {
8501
+ break;
8502
+ }
8501
8503
 
8502
- if (i !== l - 1) {
8503
- b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
8504
+ // Horizontal rule found
8505
+ if (hrRegex.test(src)) {
8506
+ break;
8507
+ }
8508
+ if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
8509
+ // Dedent if possible
8510
+ itemContents += '\n' + nextLine.slice(indent);
8511
+ } else {
8512
+ // not enough indentation
8513
+ if (blankLine) {
8514
+ break;
8515
+ }
8504
8516
 
8505
- if (isordered ? b.length === 1 || !isparen && b[b.length - 1] === ')' : b.length > 1 || this.options.smartLists && b !== bull) {
8506
- addBack = itemMatch.slice(i + 1).join('\n');
8507
- list.raw = list.raw.substring(0, list.raw.length - addBack.length);
8508
- i = l - 1;
8517
+ // paragraph continuation unless last line was a different block level element
8518
+ if (line.search(/[^ ]/) >= 4) {
8519
+ // indented code block
8520
+ break;
8521
+ }
8522
+ if (fencesBeginRegex.test(line)) {
8523
+ break;
8524
+ }
8525
+ if (headingBeginRegex.test(line)) {
8526
+ break;
8527
+ }
8528
+ if (hrRegex.test(line)) {
8529
+ break;
8530
+ }
8531
+ itemContents += '\n' + nextLine;
8532
+ }
8533
+ if (!blankLine && !nextLine.trim()) {
8534
+ // Check if current line is blank
8535
+ blankLine = true;
8536
+ }
8537
+ raw += rawLine + '\n';
8538
+ src = src.substring(rawLine.length + 1);
8539
+ line = nextLine.slice(indent);
8509
8540
  }
8510
- } // Determine whether item is loose or not.
8511
- // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
8512
- // for discount behavior.
8513
-
8514
-
8515
- loose = next || /\n\n(?!\s*$)/.test(item);
8516
-
8517
- if (i !== l - 1) {
8518
- next = item.charAt(item.length - 1) === '\n';
8519
- if (!loose) loose = next;
8520
8541
  }
8521
-
8522
- if (loose) {
8523
- list.loose = true;
8524
- } // Check for task list items
8525
-
8526
-
8527
- istask = /^\[[ xX]\] /.test(item);
8528
- ischecked = undefined;
8529
-
8530
- if (istask) {
8531
- ischecked = item[1] !== ' ';
8532
- item = item.replace(/^\[[ xX]\] +/, '');
8542
+ if (!list.loose) {
8543
+ // If the previous item ended with a blank line, the list is loose
8544
+ if (endsWithBlankLine) {
8545
+ list.loose = true;
8546
+ } else if (/\n *\n *$/.test(raw)) {
8547
+ endsWithBlankLine = true;
8548
+ }
8533
8549
  }
8534
8550
 
8551
+ // Check for task list items
8552
+ if (this.options.gfm) {
8553
+ istask = /^\[[ xX]\] /.exec(itemContents);
8554
+ if (istask) {
8555
+ ischecked = istask[0] !== '[ ] ';
8556
+ itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
8557
+ }
8558
+ }
8535
8559
  list.items.push({
8536
8560
  type: 'list_item',
8537
8561
  raw: raw,
8538
- task: istask,
8562
+ task: !!istask,
8539
8563
  checked: ischecked,
8540
- loose: loose,
8541
- text: item
8564
+ loose: false,
8565
+ text: itemContents
8542
8566
  });
8567
+ list.raw += raw;
8568
+ }
8569
+
8570
+ // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
8571
+ list.items[list.items.length - 1].raw = raw.trimRight();
8572
+ list.items[list.items.length - 1].text = itemContents.trimRight();
8573
+ list.raw = list.raw.trimRight();
8574
+ var l = list.items.length;
8575
+
8576
+ // Item child tokens handled here at end because we needed to have the final item to trim it first
8577
+ for (i = 0; i < l; i++) {
8578
+ this.lexer.state.top = false;
8579
+ list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
8580
+ if (!list.loose) {
8581
+ // Check if list should be loose
8582
+ var spacers = list.items[i].tokens.filter(function (t) {
8583
+ return t.type === 'space';
8584
+ });
8585
+ var hasMultipleLineBreaks = spacers.length > 0 && spacers.some(function (t) {
8586
+ return /\n.*\n/.test(t.raw);
8587
+ });
8588
+ list.loose = hasMultipleLineBreaks;
8589
+ }
8543
8590
  }
8544
8591
 
8592
+ // Set all items to loose if list is loose
8593
+ if (list.loose) {
8594
+ for (i = 0; i < l; i++) {
8595
+ list.items[i].loose = true;
8596
+ }
8597
+ }
8545
8598
  return list;
8546
8599
  }
8547
8600
  };
8548
-
8549
8601
  _proto.html = function html(src) {
8550
8602
  var cap = this.rules.block.html.exec(src);
8551
-
8552
8603
  if (cap) {
8553
- return {
8554
- type: this.options.sanitize ? 'paragraph' : 'html',
8604
+ var token = {
8605
+ type: 'html',
8555
8606
  raw: cap[0],
8556
8607
  pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
8557
- text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
8608
+ text: cap[0]
8558
8609
  };
8610
+ if (this.options.sanitize) {
8611
+ var text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
8612
+ token.type = 'paragraph';
8613
+ token.text = text;
8614
+ token.tokens = this.lexer.inline(text);
8615
+ }
8616
+ return token;
8559
8617
  }
8560
8618
  };
8561
-
8562
8619
  _proto.def = function def(src) {
8563
8620
  var cap = this.rules.block.def.exec(src);
8564
-
8565
8621
  if (cap) {
8566
- if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
8567
8622
  var tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
8623
+ var href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline._escapes, '$1') : '';
8624
+ var title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline._escapes, '$1') : cap[3];
8568
8625
  return {
8626
+ type: 'def',
8569
8627
  tag: tag,
8570
8628
  raw: cap[0],
8571
- href: cap[2],
8572
- title: cap[3]
8629
+ href: href,
8630
+ title: title
8573
8631
  };
8574
8632
  }
8575
8633
  };
8576
-
8577
8634
  _proto.table = function table(src) {
8578
8635
  var cap = this.rules.block.table.exec(src);
8579
-
8580
8636
  if (cap) {
8581
8637
  var item = {
8582
8638
  type: 'table',
8583
- header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
8639
+ header: splitCells(cap[1]).map(function (c) {
8640
+ return {
8641
+ text: c
8642
+ };
8643
+ }),
8584
8644
  align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
8585
- cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
8645
+ rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
8586
8646
  };
8587
-
8588
8647
  if (item.header.length === item.align.length) {
8589
8648
  item.raw = cap[0];
8590
8649
  var l = item.align.length;
8591
- var i;
8592
-
8650
+ var i, j, k, row;
8593
8651
  for (i = 0; i < l; i++) {
8594
8652
  if (/^ *-+: *$/.test(item.align[i])) {
8595
8653
  item.align[i] = 'right';
@@ -8601,149 +8659,161 @@ var marked = createCommonjsModule(function (module, exports) {
8601
8659
  item.align[i] = null;
8602
8660
  }
8603
8661
  }
8662
+ l = item.rows.length;
8663
+ for (i = 0; i < l; i++) {
8664
+ item.rows[i] = splitCells(item.rows[i], item.header.length).map(function (c) {
8665
+ return {
8666
+ text: c
8667
+ };
8668
+ });
8669
+ }
8604
8670
 
8605
- l = item.cells.length;
8671
+ // parse child tokens inside headers and cells
8606
8672
 
8607
- for (i = 0; i < l; i++) {
8608
- item.cells[i] = splitCells$1(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
8673
+ // header child tokens
8674
+ l = item.header.length;
8675
+ for (j = 0; j < l; j++) {
8676
+ item.header[j].tokens = this.lexer.inline(item.header[j].text);
8609
8677
  }
8610
8678
 
8679
+ // cell child tokens
8680
+ l = item.rows.length;
8681
+ for (j = 0; j < l; j++) {
8682
+ row = item.rows[j];
8683
+ for (k = 0; k < row.length; k++) {
8684
+ row[k].tokens = this.lexer.inline(row[k].text);
8685
+ }
8686
+ }
8611
8687
  return item;
8612
8688
  }
8613
8689
  }
8614
8690
  };
8615
-
8616
8691
  _proto.lheading = function lheading(src) {
8617
8692
  var cap = this.rules.block.lheading.exec(src);
8618
-
8619
8693
  if (cap) {
8620
8694
  return {
8621
8695
  type: 'heading',
8622
8696
  raw: cap[0],
8623
8697
  depth: cap[2].charAt(0) === '=' ? 1 : 2,
8624
- text: cap[1]
8698
+ text: cap[1],
8699
+ tokens: this.lexer.inline(cap[1])
8625
8700
  };
8626
8701
  }
8627
8702
  };
8628
-
8629
8703
  _proto.paragraph = function paragraph(src) {
8630
8704
  var cap = this.rules.block.paragraph.exec(src);
8631
-
8632
8705
  if (cap) {
8706
+ var text = cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1];
8633
8707
  return {
8634
8708
  type: 'paragraph',
8635
8709
  raw: cap[0],
8636
- text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
8710
+ text: text,
8711
+ tokens: this.lexer.inline(text)
8637
8712
  };
8638
8713
  }
8639
8714
  };
8640
-
8641
- _proto.text = function text(src, tokens) {
8715
+ _proto.text = function text(src) {
8642
8716
  var cap = this.rules.block.text.exec(src);
8643
-
8644
8717
  if (cap) {
8645
- var lastToken = tokens[tokens.length - 1];
8646
-
8647
- if (lastToken && lastToken.type === 'text') {
8648
- return {
8649
- raw: cap[0],
8650
- text: cap[0]
8651
- };
8652
- }
8653
-
8654
8718
  return {
8655
8719
  type: 'text',
8656
8720
  raw: cap[0],
8657
- text: cap[0]
8721
+ text: cap[0],
8722
+ tokens: this.lexer.inline(cap[0])
8658
8723
  };
8659
8724
  }
8660
8725
  };
8661
-
8662
- _proto.escape = function escape(src) {
8726
+ _proto.escape = function escape$1(src) {
8663
8727
  var cap = this.rules.inline.escape.exec(src);
8664
-
8665
8728
  if (cap) {
8666
8729
  return {
8667
8730
  type: 'escape',
8668
8731
  raw: cap[0],
8669
- text: _escape(cap[1])
8732
+ text: escape(cap[1])
8670
8733
  };
8671
8734
  }
8672
8735
  };
8673
-
8674
- _proto.tag = function tag(src, inLink, inRawBlock) {
8736
+ _proto.tag = function tag(src) {
8675
8737
  var cap = this.rules.inline.tag.exec(src);
8676
-
8677
8738
  if (cap) {
8678
- if (!inLink && /^<a /i.test(cap[0])) {
8679
- inLink = true;
8680
- } else if (inLink && /^<\/a>/i.test(cap[0])) {
8681
- inLink = false;
8739
+ if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
8740
+ this.lexer.state.inLink = true;
8741
+ } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
8742
+ this.lexer.state.inLink = false;
8682
8743
  }
8683
-
8684
- if (!inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
8685
- inRawBlock = true;
8686
- } else if (inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
8687
- inRawBlock = false;
8744
+ if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
8745
+ this.lexer.state.inRawBlock = true;
8746
+ } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
8747
+ this.lexer.state.inRawBlock = false;
8688
8748
  }
8689
-
8690
8749
  return {
8691
8750
  type: this.options.sanitize ? 'text' : 'html',
8692
8751
  raw: cap[0],
8693
- inLink: inLink,
8694
- inRawBlock: inRawBlock,
8695
- text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0]
8752
+ inLink: this.lexer.state.inLink,
8753
+ inRawBlock: this.lexer.state.inRawBlock,
8754
+ text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0]
8696
8755
  };
8697
8756
  }
8698
8757
  };
8699
-
8700
8758
  _proto.link = function link(src) {
8701
8759
  var cap = this.rules.inline.link.exec(src);
8702
-
8703
8760
  if (cap) {
8704
- var lastParenIndex = findClosingBracket$1(cap[2], '()');
8761
+ var trimmedUrl = cap[2].trim();
8762
+ if (!this.options.pedantic && /^</.test(trimmedUrl)) {
8763
+ // commonmark requires matching angle brackets
8764
+ if (!/>$/.test(trimmedUrl)) {
8765
+ return;
8766
+ }
8705
8767
 
8706
- if (lastParenIndex > -1) {
8707
- var start = cap[0].indexOf('!') === 0 ? 5 : 4;
8708
- var linkLen = start + cap[1].length + lastParenIndex;
8709
- cap[2] = cap[2].substring(0, lastParenIndex);
8710
- cap[0] = cap[0].substring(0, linkLen).trim();
8711
- cap[3] = '';
8768
+ // ending angle bracket cannot be escaped
8769
+ var rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
8770
+ if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
8771
+ return;
8772
+ }
8773
+ } else {
8774
+ // find closing parenthesis
8775
+ var lastParenIndex = findClosingBracket(cap[2], '()');
8776
+ if (lastParenIndex > -1) {
8777
+ var start = cap[0].indexOf('!') === 0 ? 5 : 4;
8778
+ var linkLen = start + cap[1].length + lastParenIndex;
8779
+ cap[2] = cap[2].substring(0, lastParenIndex);
8780
+ cap[0] = cap[0].substring(0, linkLen).trim();
8781
+ cap[3] = '';
8782
+ }
8712
8783
  }
8713
-
8714
8784
  var href = cap[2];
8715
8785
  var title = '';
8716
-
8717
8786
  if (this.options.pedantic) {
8787
+ // split pedantic href and title
8718
8788
  var link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
8719
-
8720
8789
  if (link) {
8721
8790
  href = link[1];
8722
8791
  title = link[3];
8723
- } else {
8724
- title = '';
8725
8792
  }
8726
8793
  } else {
8727
8794
  title = cap[3] ? cap[3].slice(1, -1) : '';
8728
8795
  }
8729
-
8730
- href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
8731
- var token = outputLink(cap, {
8796
+ href = href.trim();
8797
+ if (/^</.test(href)) {
8798
+ if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
8799
+ // pedantic allows starting angle bracket without ending angle bracket
8800
+ href = href.slice(1);
8801
+ } else {
8802
+ href = href.slice(1, -1);
8803
+ }
8804
+ }
8805
+ return outputLink(cap, {
8732
8806
  href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
8733
8807
  title: title ? title.replace(this.rules.inline._escapes, '$1') : title
8734
- }, cap[0]);
8735
- return token;
8808
+ }, cap[0], this.lexer);
8736
8809
  }
8737
8810
  };
8738
-
8739
8811
  _proto.reflink = function reflink(src, links) {
8740
8812
  var cap;
8741
-
8742
8813
  if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
8743
8814
  var link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
8744
8815
  link = links[link.toLowerCase()];
8745
-
8746
- if (!link || !link.href) {
8816
+ if (!link) {
8747
8817
  var text = cap[0].charAt(0);
8748
8818
  return {
8749
8819
  type: 'text',
@@ -8751,79 +8821,86 @@ var marked = createCommonjsModule(function (module, exports) {
8751
8821
  text: text
8752
8822
  };
8753
8823
  }
8754
-
8755
- var token = outputLink(cap, link, cap[0]);
8756
- return token;
8824
+ return outputLink(cap, link, cap[0], this.lexer);
8757
8825
  }
8758
8826
  };
8759
-
8760
- _proto.strong = function strong(src, maskedSrc, prevChar) {
8827
+ _proto.emStrong = function emStrong(src, maskedSrc, prevChar) {
8761
8828
  if (prevChar === void 0) {
8762
8829
  prevChar = '';
8763
8830
  }
8764
-
8765
- var match = this.rules.inline.strong.start.exec(src);
8766
-
8767
- if (match && (!match[1] || match[1] && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
8768
- maskedSrc = maskedSrc.slice(-1 * src.length);
8769
- var endReg = match[0] === '**' ? this.rules.inline.strong.endAst : this.rules.inline.strong.endUnd;
8831
+ var match = this.rules.inline.emStrong.lDelim.exec(src);
8832
+ if (!match) return;
8833
+
8834
+ // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
8835
+ if (match[3] && prevChar.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDF70-\uDF81\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/)) return;
8836
+ var nextChar = match[1] || match[2] || '';
8837
+ if (!nextChar || nextChar && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar))) {
8838
+ var lLength = match[0].length - 1;
8839
+ var rDelim,
8840
+ rLength,
8841
+ delimTotal = lLength,
8842
+ midDelimTotal = 0;
8843
+ var endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
8770
8844
  endReg.lastIndex = 0;
8771
- var cap;
8772
8845
 
8846
+ // Clip maskedSrc to same section of string as src (move to lexer?)
8847
+ maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
8773
8848
  while ((match = endReg.exec(maskedSrc)) != null) {
8774
- cap = this.rules.inline.strong.middle.exec(maskedSrc.slice(0, match.index + 3));
8849
+ rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
8850
+ if (!rDelim) continue; // skip single * in __abc*abc__
8775
8851
 
8776
- if (cap) {
8777
- return {
8778
- type: 'strong',
8779
- raw: src.slice(0, cap[0].length),
8780
- text: src.slice(2, cap[0].length - 2)
8781
- };
8852
+ rLength = rDelim.length;
8853
+ if (match[3] || match[4]) {
8854
+ // found another Left Delim
8855
+ delimTotal += rLength;
8856
+ continue;
8857
+ } else if (match[5] || match[6]) {
8858
+ // either Left or Right Delim
8859
+ if (lLength % 3 && !((lLength + rLength) % 3)) {
8860
+ midDelimTotal += rLength;
8861
+ continue; // CommonMark Emphasis Rules 9-10
8862
+ }
8782
8863
  }
8783
- }
8784
- }
8785
- };
8786
-
8787
- _proto.em = function em(src, maskedSrc, prevChar) {
8788
- if (prevChar === void 0) {
8789
- prevChar = '';
8790
- }
8791
8864
 
8792
- var match = this.rules.inline.em.start.exec(src);
8793
-
8794
- if (match && (!match[1] || match[1] && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
8795
- maskedSrc = maskedSrc.slice(-1 * src.length);
8796
- var endReg = match[0] === '*' ? this.rules.inline.em.endAst : this.rules.inline.em.endUnd;
8797
- endReg.lastIndex = 0;
8798
- var cap;
8865
+ delimTotal -= rLength;
8866
+ if (delimTotal > 0) continue; // Haven't found enough closing delimiters
8799
8867
 
8800
- while ((match = endReg.exec(maskedSrc)) != null) {
8801
- cap = this.rules.inline.em.middle.exec(maskedSrc.slice(0, match.index + 2));
8868
+ // Remove extra characters. *a*** -> *a*
8869
+ rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
8870
+ var raw = src.slice(0, lLength + match.index + (match[0].length - rDelim.length) + rLength);
8802
8871
 
8803
- if (cap) {
8872
+ // Create `em` if smallest delimiter has odd char count. *a***
8873
+ if (Math.min(lLength, rLength) % 2) {
8874
+ var _text = raw.slice(1, -1);
8804
8875
  return {
8805
8876
  type: 'em',
8806
- raw: src.slice(0, cap[0].length),
8807
- text: src.slice(1, cap[0].length - 1)
8877
+ raw: raw,
8878
+ text: _text,
8879
+ tokens: this.lexer.inlineTokens(_text)
8808
8880
  };
8809
8881
  }
8882
+
8883
+ // Create 'strong' if smallest delimiter has even char count. **a***
8884
+ var text = raw.slice(2, -2);
8885
+ return {
8886
+ type: 'strong',
8887
+ raw: raw,
8888
+ text: text,
8889
+ tokens: this.lexer.inlineTokens(text)
8890
+ };
8810
8891
  }
8811
8892
  }
8812
8893
  };
8813
-
8814
8894
  _proto.codespan = function codespan(src) {
8815
8895
  var cap = this.rules.inline.code.exec(src);
8816
-
8817
8896
  if (cap) {
8818
8897
  var text = cap[2].replace(/\n/g, ' ');
8819
8898
  var hasNonSpaceChars = /[^ ]/.test(text);
8820
- var hasSpaceCharsOnBothEnds = text.startsWith(' ') && text.endsWith(' ');
8821
-
8899
+ var hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
8822
8900
  if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
8823
8901
  text = text.substring(1, text.length - 1);
8824
8902
  }
8825
-
8826
- text = _escape(text, true);
8903
+ text = escape(text, true);
8827
8904
  return {
8828
8905
  type: 'codespan',
8829
8906
  raw: cap[0],
@@ -8831,10 +8908,8 @@ var marked = createCommonjsModule(function (module, exports) {
8831
8908
  };
8832
8909
  }
8833
8910
  };
8834
-
8835
8911
  _proto.br = function br(src) {
8836
8912
  var cap = this.rules.inline.br.exec(src);
8837
-
8838
8913
  if (cap) {
8839
8914
  return {
8840
8915
  type: 'br',
@@ -8842,33 +8917,28 @@ var marked = createCommonjsModule(function (module, exports) {
8842
8917
  };
8843
8918
  }
8844
8919
  };
8845
-
8846
8920
  _proto.del = function del(src) {
8847
8921
  var cap = this.rules.inline.del.exec(src);
8848
-
8849
8922
  if (cap) {
8850
8923
  return {
8851
8924
  type: 'del',
8852
8925
  raw: cap[0],
8853
- text: cap[1]
8926
+ text: cap[2],
8927
+ tokens: this.lexer.inlineTokens(cap[2])
8854
8928
  };
8855
8929
  }
8856
8930
  };
8857
-
8858
8931
  _proto.autolink = function autolink(src, mangle) {
8859
8932
  var cap = this.rules.inline.autolink.exec(src);
8860
-
8861
8933
  if (cap) {
8862
8934
  var text, href;
8863
-
8864
8935
  if (cap[2] === '@') {
8865
- text = _escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
8936
+ text = escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
8866
8937
  href = 'mailto:' + text;
8867
8938
  } else {
8868
- text = _escape(cap[1]);
8939
+ text = escape(cap[1]);
8869
8940
  href = text;
8870
8941
  }
8871
-
8872
8942
  return {
8873
8943
  type: 'link',
8874
8944
  raw: cap[0],
@@ -8882,34 +8952,27 @@ var marked = createCommonjsModule(function (module, exports) {
8882
8952
  };
8883
8953
  }
8884
8954
  };
8885
-
8886
8955
  _proto.url = function url(src, mangle) {
8887
8956
  var cap;
8888
-
8889
8957
  if (cap = this.rules.inline.url.exec(src)) {
8890
8958
  var text, href;
8891
-
8892
8959
  if (cap[2] === '@') {
8893
- text = _escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
8960
+ text = escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
8894
8961
  href = 'mailto:' + text;
8895
8962
  } else {
8896
8963
  // do extended autolink path validation
8897
8964
  var prevCapZero;
8898
-
8899
8965
  do {
8900
8966
  prevCapZero = cap[0];
8901
8967
  cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
8902
8968
  } while (prevCapZero !== cap[0]);
8903
-
8904
- text = _escape(cap[0]);
8905
-
8969
+ text = escape(cap[0]);
8906
8970
  if (cap[1] === 'www.') {
8907
- href = 'http://' + text;
8971
+ href = 'http://' + cap[0];
8908
8972
  } else {
8909
- href = text;
8973
+ href = cap[0];
8910
8974
  }
8911
8975
  }
8912
-
8913
8976
  return {
8914
8977
  type: 'link',
8915
8978
  raw: cap[0],
@@ -8923,19 +8986,15 @@ var marked = createCommonjsModule(function (module, exports) {
8923
8986
  };
8924
8987
  }
8925
8988
  };
8926
-
8927
- _proto.inlineText = function inlineText(src, inRawBlock, smartypants) {
8989
+ _proto.inlineText = function inlineText(src, smartypants) {
8928
8990
  var cap = this.rules.inline.text.exec(src);
8929
-
8930
8991
  if (cap) {
8931
8992
  var text;
8932
-
8933
- if (inRawBlock) {
8934
- text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : _escape(cap[0]) : cap[0];
8993
+ if (this.lexer.state.inRawBlock) {
8994
+ text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
8935
8995
  } else {
8936
- text = _escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
8996
+ text = escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
8937
8997
  }
8938
-
8939
8998
  return {
8940
8999
  type: 'text',
8941
9000
  raw: cap[0],
@@ -8943,105 +9002,99 @@ var marked = createCommonjsModule(function (module, exports) {
8943
9002
  };
8944
9003
  }
8945
9004
  };
8946
-
8947
9005
  return Tokenizer;
8948
9006
  }();
8949
9007
 
8950
- var noopTest$1 = helpers.noopTest,
8951
- edit$1 = helpers.edit,
8952
- merge$1 = helpers.merge;
8953
9008
  /**
8954
9009
  * Block-Level Grammar
8955
9010
  */
8956
-
8957
9011
  var block = {
8958
- newline: /^\n+/,
8959
- code: /^( {4}[^\n]+\n*)+/,
8960
- fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
8961
- hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
8962
- heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
9012
+ newline: /^(?: *(?:\n|$))+/,
9013
+ code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
9014
+ fences: /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
9015
+ hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
9016
+ heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
8963
9017
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
8964
- list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
9018
+ list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
8965
9019
  html: '^ {0,3}(?:' // optional indentation
8966
- + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
9020
+ + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
8967
9021
  + '|comment[^\\n]*(\\n+|$)' // (2)
8968
- + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
8969
- + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
8970
- + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
8971
- + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
8972
- + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
8973
- + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
9022
+ + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
9023
+ + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
9024
+ + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
9025
+ + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
9026
+ + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
9027
+ + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
8974
9028
  + ')',
8975
- def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
8976
- nptable: noopTest$1,
8977
- table: noopTest$1,
8978
- lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
9029
+ def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
9030
+ table: noopTest,
9031
+ lheading: /^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
8979
9032
  // regex template, placeholders will be replaced according to different paragraph
8980
9033
  // interruption rules of commonmark and the original markdown spec:
8981
- _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
9034
+ _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
8982
9035
  text: /^[^\n]+/
8983
9036
  };
8984
- block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
9037
+ block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
8985
9038
  block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
8986
- block.def = edit$1(block.def).replace('label', block._label).replace('title', block._title).getRegex();
9039
+ block.def = edit(block.def).replace('label', block._label).replace('title', block._title).getRegex();
8987
9040
  block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
8988
- block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
8989
- block.item = edit$1(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
8990
- block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
9041
+ block.listItemStart = edit(/^( *)(bull) */).replace('bull', block.bullet).getRegex();
9042
+ block.list = edit(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
8991
9043
  block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
8992
- block._comment = /<!--(?!-?>)[\s\S]*?-->/;
8993
- block.html = edit$1(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
8994
- block.paragraph = edit$1(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
8995
- .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
8996
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
9044
+ block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
9045
+ block.html = edit(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
9046
+ block.paragraph = edit(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
9047
+ .replace('|table', '').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
9048
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
8997
9049
  .getRegex();
8998
- block.blockquote = edit$1(block.blockquote).replace('paragraph', block.paragraph).getRegex();
9050
+ block.blockquote = edit(block.blockquote).replace('paragraph', block.paragraph).getRegex();
9051
+
8999
9052
  /**
9000
9053
  * Normal Block Grammar
9001
9054
  */
9002
9055
 
9003
- block.normal = merge$1({}, block);
9056
+ block.normal = _extends({}, block);
9057
+
9004
9058
  /**
9005
9059
  * GFM Block Grammar
9006
9060
  */
9007
9061
 
9008
- block.gfm = merge$1({}, block.normal, {
9009
- nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
9010
- + ' *([-:]+ *\\|[-| :]*)' // Align
9011
- + '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)',
9012
- // Cells
9013
- table: '^ *\\|(.+)\\n' // Header
9014
- + ' *\\|?( *[-:]+[-| :]*)' // Align
9015
- + '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
9016
-
9062
+ block.gfm = _extends({}, block.normal, {
9063
+ table: '^ *([^\\n ].*\\|.*)\\n' // Header
9064
+ + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
9065
+ + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
9017
9066
  });
9018
- block.gfm.nptable = edit$1(block.gfm.nptable).replace('hr', block.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
9019
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
9067
+
9068
+ block.gfm.table = edit(block.gfm.table).replace('hr', block.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
9069
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
9020
9070
  .getRegex();
9021
- block.gfm.table = edit$1(block.gfm.table).replace('hr', block.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
9022
- .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)').replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
9071
+ block.gfm.paragraph = edit(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
9072
+ .replace('table', block.gfm.table) // interrupt paragraphs with table
9073
+ .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
9074
+ .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
9023
9075
  .getRegex();
9024
9076
  /**
9025
9077
  * Pedantic grammar (original John Gruber's loose markdown specification)
9026
9078
  */
9027
9079
 
9028
- block.pedantic = merge$1({}, block.normal, {
9029
- html: edit$1('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
9080
+ block.pedantic = _extends({}, block.normal, {
9081
+ html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
9030
9082
  + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
9031
9083
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
9032
- heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
9033
- fences: noopTest$1,
9084
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
9085
+ fences: noopTest,
9034
9086
  // fences not supported
9035
- paragraph: edit$1(block.normal._paragraph).replace('hr', block.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
9087
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
9088
+ paragraph: edit(block.normal._paragraph).replace('hr', block.hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', block.lheading).replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').getRegex()
9036
9089
  });
9090
+
9037
9091
  /**
9038
9092
  * Inline-Level Grammar
9039
9093
  */
9040
-
9041
9094
  var inline = {
9042
9095
  escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
9043
9096
  autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
9044
- url: noopTest$1,
9097
+ url: noopTest,
9045
9098
  tag: '^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
9046
9099
  + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
9047
9100
  + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
@@ -9049,72 +9102,63 @@ var marked = createCommonjsModule(function (module, exports) {
9049
9102
  + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
9050
9103
  // CDATA section
9051
9104
  link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
9052
- reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
9053
- nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
9105
+ reflink: /^!?\[(label)\]\[(ref)\]/,
9106
+ nolink: /^!?\[(ref)\](?:\[\])?/,
9054
9107
  reflinkSearch: 'reflink|nolink(?!\\()',
9055
- strong: {
9056
- start: /^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,
9057
- // (1) returns if starts w/ punctuation
9058
- middle: /^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,
9059
- endAst: /[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,
9060
- // last char can't be punct, or final * must also be followed by punct (or endline)
9061
- endUnd: /[^\s]__(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline)
9062
-
9108
+ emStrong: {
9109
+ lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
9110
+ // (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.
9111
+ // () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
9112
+ rDelimAst: /^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,
9113
+ rDelimUnd: /^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
9063
9114
  },
9064
- em: {
9065
- start: /^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,
9066
- // (1) returns if starts w/ punctuation
9067
- middle: /^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,
9068
- endAst: /[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,
9069
- // last char can't be punct, or final * must also be followed by punct (or endline)
9070
- endUnd: /[^\s]_(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline)
9071
9115
 
9072
- },
9073
9116
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
9074
9117
  br: /^( {2,}|\\)\n(?!\s*$)/,
9075
- del: noopTest$1,
9076
- text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,
9077
- punctuation: /^([\s*punctuation])/
9078
- }; // list of punctuation marks from common mark spec
9079
- // without * and _ to workaround cases with double emphasis
9118
+ del: noopTest,
9119
+ text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
9120
+ punctuation: /^([\spunctuation])/
9121
+ };
9080
9122
 
9123
+ // list of punctuation marks from CommonMark spec
9124
+ // without * and _ to handle the different emphasis markers * and _
9081
9125
  inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
9082
- inline.punctuation = edit$1(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex(); // sequences em should skip over [title](link), `code`, <html>
9083
-
9084
- inline._blockSkip = '\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>';
9085
- inline._overlapSkip = '__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*';
9086
- inline.em.start = edit$1(inline.em.start).replace(/punctuation/g, inline._punctuation).getRegex();
9087
- inline.em.middle = edit$1(inline.em.middle).replace(/punctuation/g, inline._punctuation).replace(/overlapSkip/g, inline._overlapSkip).getRegex();
9088
- inline.em.endAst = edit$1(inline.em.endAst, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
9089
- inline.em.endUnd = edit$1(inline.em.endUnd, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
9090
- inline.strong.start = edit$1(inline.strong.start).replace(/punctuation/g, inline._punctuation).getRegex();
9091
- inline.strong.middle = edit$1(inline.strong.middle).replace(/punctuation/g, inline._punctuation).replace(/blockSkip/g, inline._blockSkip).getRegex();
9092
- inline.strong.endAst = edit$1(inline.strong.endAst, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
9093
- inline.strong.endUnd = edit$1(inline.strong.endUnd, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
9094
- inline.blockSkip = edit$1(inline._blockSkip, 'g').getRegex();
9095
- inline.overlapSkip = edit$1(inline._overlapSkip, 'g').getRegex();
9126
+ inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
9127
+
9128
+ // sequences em should skip over [title](link), `code`, <html>
9129
+ inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
9130
+ // lookbehind is not available on Safari as of version 16
9131
+ // inline.escapedEmSt = /(?<=(?:^|[^\\)(?:\\[^])*)\\[*_]/g;
9132
+ inline.escapedEmSt = /(?:^|[^\\])(?:\\\\)*\\[*_]/g;
9133
+ inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
9134
+ inline.emStrong.lDelim = edit(inline.emStrong.lDelim).replace(/punct/g, inline._punctuation).getRegex();
9135
+ inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'g').replace(/punct/g, inline._punctuation).getRegex();
9136
+ inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'g').replace(/punct/g, inline._punctuation).getRegex();
9096
9137
  inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
9097
9138
  inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
9098
9139
  inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
9099
- inline.autolink = edit$1(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
9140
+ inline.autolink = edit(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
9100
9141
  inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
9101
- inline.tag = edit$1(inline.tag).replace('comment', block._comment).replace('attribute', inline._attribute).getRegex();
9142
+ inline.tag = edit(inline.tag).replace('comment', inline._comment).replace('attribute', inline._attribute).getRegex();
9102
9143
  inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
9103
- inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
9144
+ inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
9104
9145
  inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
9105
- inline.link = edit$1(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
9106
- inline.reflink = edit$1(inline.reflink).replace('label', inline._label).getRegex();
9107
- inline.reflinkSearch = edit$1(inline.reflinkSearch, 'g').replace('reflink', inline.reflink).replace('nolink', inline.nolink).getRegex();
9146
+ inline.link = edit(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
9147
+ inline.reflink = edit(inline.reflink).replace('label', inline._label).replace('ref', block._label).getRegex();
9148
+ inline.nolink = edit(inline.nolink).replace('ref', block._label).getRegex();
9149
+ inline.reflinkSearch = edit(inline.reflinkSearch, 'g').replace('reflink', inline.reflink).replace('nolink', inline.nolink).getRegex();
9150
+
9108
9151
  /**
9109
9152
  * Normal Inline Grammar
9110
9153
  */
9111
9154
 
9112
- inline.normal = merge$1({}, inline);
9155
+ inline.normal = _extends({}, inline);
9156
+
9113
9157
  /**
9114
9158
  * Pedantic Inline Grammar
9115
9159
  */
9116
9160
 
9117
- inline.pedantic = merge$1({}, inline.normal, {
9161
+ inline.pedantic = _extends({}, inline.normal, {
9118
9162
  strong: {
9119
9163
  start: /^__|\*\*/,
9120
9164
  middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
@@ -9127,113 +9171,112 @@ var marked = createCommonjsModule(function (module, exports) {
9127
9171
  endAst: /\*(?!\*)/g,
9128
9172
  endUnd: /_(?!_)/g
9129
9173
  },
9130
- link: edit$1(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
9131
- reflink: edit$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
9174
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
9175
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
9132
9176
  });
9177
+
9133
9178
  /**
9134
9179
  * GFM Inline Grammar
9135
9180
  */
9136
9181
 
9137
- inline.gfm = merge$1({}, inline.normal, {
9138
- escape: edit$1(inline.escape).replace('])', '~|])').getRegex(),
9182
+ inline.gfm = _extends({}, inline.normal, {
9183
+ escape: edit(inline.escape).replace('])', '~|])').getRegex(),
9139
9184
  _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
9140
9185
  url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
9141
- _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
9142
- del: /^~+(?=\S)([\s\S]*?\S)~+/,
9143
- text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
9186
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
9187
+ del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
9188
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
9144
9189
  });
9145
- inline.gfm.url = edit$1(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
9190
+ inline.gfm.url = edit(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
9146
9191
  /**
9147
9192
  * GFM + Line Breaks Inline Grammar
9148
9193
  */
9149
9194
 
9150
- inline.breaks = merge$1({}, inline.gfm, {
9151
- br: edit$1(inline.br).replace('{2,}', '*').getRegex(),
9152
- text: edit$1(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
9195
+ inline.breaks = _extends({}, inline.gfm, {
9196
+ br: edit(inline.br).replace('{2,}', '*').getRegex(),
9197
+ text: edit(inline.gfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
9153
9198
  });
9154
- var rules = {
9155
- block: block,
9156
- inline: inline
9157
- };
9158
9199
 
9159
- var defaults$2 = defaults.defaults;
9160
- var block$1 = rules.block,
9161
- inline$1 = rules.inline;
9162
9200
  /**
9163
9201
  * smartypants text replacement
9202
+ * @param {string} text
9164
9203
  */
9165
-
9166
9204
  function smartypants(text) {
9167
- return text // em-dashes
9168
- .replace(/---/g, "\u2014") // en-dashes
9169
- .replace(/--/g, "\u2013") // opening singles
9170
- .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // closing singles & apostrophes
9171
- .replace(/'/g, "\u2019") // opening doubles
9172
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C") // closing doubles
9173
- .replace(/"/g, "\u201D") // ellipses
9205
+ return text
9206
+ // em-dashes
9207
+ .replace(/---/g, "\u2014")
9208
+ // en-dashes
9209
+ .replace(/--/g, "\u2013")
9210
+ // opening singles
9211
+ .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018")
9212
+ // closing singles & apostrophes
9213
+ .replace(/'/g, "\u2019")
9214
+ // opening doubles
9215
+ .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C")
9216
+ // closing doubles
9217
+ .replace(/"/g, "\u201D")
9218
+ // ellipses
9174
9219
  .replace(/\.{3}/g, "\u2026");
9175
9220
  }
9221
+
9176
9222
  /**
9177
9223
  * mangle email addresses
9224
+ * @param {string} text
9178
9225
  */
9179
-
9180
-
9181
9226
  function mangle(text) {
9182
9227
  var out = '',
9183
- i,
9184
- ch;
9228
+ i,
9229
+ ch;
9185
9230
  var l = text.length;
9186
-
9187
9231
  for (i = 0; i < l; i++) {
9188
9232
  ch = text.charCodeAt(i);
9189
-
9190
9233
  if (Math.random() > 0.5) {
9191
9234
  ch = 'x' + ch.toString(16);
9192
9235
  }
9193
-
9194
9236
  out += '&#' + ch + ';';
9195
9237
  }
9196
-
9197
9238
  return out;
9198
9239
  }
9240
+
9199
9241
  /**
9200
9242
  * Block Lexer
9201
9243
  */
9202
-
9203
-
9204
- var Lexer_1 = /*#__PURE__*/function () {
9244
+ var Lexer = /*#__PURE__*/function () {
9205
9245
  function Lexer(options) {
9206
9246
  this.tokens = [];
9207
9247
  this.tokens.links = Object.create(null);
9208
- this.options = options || defaults$2;
9209
- this.options.tokenizer = this.options.tokenizer || new Tokenizer_1();
9248
+ this.options = options || exports.defaults;
9249
+ this.options.tokenizer = this.options.tokenizer || new Tokenizer();
9210
9250
  this.tokenizer = this.options.tokenizer;
9211
9251
  this.tokenizer.options = this.options;
9252
+ this.tokenizer.lexer = this;
9253
+ this.inlineQueue = [];
9254
+ this.state = {
9255
+ inLink: false,
9256
+ inRawBlock: false,
9257
+ top: true
9258
+ };
9212
9259
  var rules = {
9213
- block: block$1.normal,
9214
- inline: inline$1.normal
9260
+ block: block.normal,
9261
+ inline: inline.normal
9215
9262
  };
9216
-
9217
9263
  if (this.options.pedantic) {
9218
- rules.block = block$1.pedantic;
9219
- rules.inline = inline$1.pedantic;
9264
+ rules.block = block.pedantic;
9265
+ rules.inline = inline.pedantic;
9220
9266
  } else if (this.options.gfm) {
9221
- rules.block = block$1.gfm;
9222
-
9267
+ rules.block = block.gfm;
9223
9268
  if (this.options.breaks) {
9224
- rules.inline = inline$1.breaks;
9269
+ rules.inline = inline.breaks;
9225
9270
  } else {
9226
- rules.inline = inline$1.gfm;
9271
+ rules.inline = inline.gfm;
9227
9272
  }
9228
9273
  }
9229
-
9230
9274
  this.tokenizer.rules = rules;
9231
9275
  }
9276
+
9232
9277
  /**
9233
9278
  * Expose Rules
9234
9279
  */
9235
-
9236
-
9237
9280
  /**
9238
9281
  * Static Lex Method
9239
9282
  */
@@ -9241,172 +9284,212 @@ var marked = createCommonjsModule(function (module, exports) {
9241
9284
  var lexer = new Lexer(options);
9242
9285
  return lexer.lex(src);
9243
9286
  }
9287
+
9244
9288
  /**
9245
- * Preprocessing
9246
- */
9247
- ;
9289
+ * Static Lex Inline Method
9290
+ */;
9291
+ Lexer.lexInline = function lexInline(src, options) {
9292
+ var lexer = new Lexer(options);
9293
+ return lexer.inlineTokens(src);
9294
+ }
9248
9295
 
9296
+ /**
9297
+ * Preprocessing
9298
+ */;
9249
9299
  var _proto = Lexer.prototype;
9250
-
9251
9300
  _proto.lex = function lex(src) {
9252
- src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ');
9253
- this.blockTokens(src, this.tokens, true);
9254
- this.inline(this.tokens);
9301
+ src = src.replace(/\r\n|\r/g, '\n');
9302
+ this.blockTokens(src, this.tokens);
9303
+ var next;
9304
+ while (next = this.inlineQueue.shift()) {
9305
+ this.inlineTokens(next.src, next.tokens);
9306
+ }
9255
9307
  return this.tokens;
9256
9308
  }
9309
+
9257
9310
  /**
9258
9311
  * Lexing
9259
- */
9260
- ;
9261
-
9262
- _proto.blockTokens = function blockTokens(src, tokens, top) {
9312
+ */;
9313
+ _proto.blockTokens = function blockTokens(src, tokens) {
9314
+ var _this = this;
9263
9315
  if (tokens === void 0) {
9264
9316
  tokens = [];
9265
9317
  }
9266
-
9267
- if (top === void 0) {
9268
- top = true;
9318
+ if (this.options.pedantic) {
9319
+ src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
9320
+ } else {
9321
+ src = src.replace(/^( *)(\t+)/gm, function (_, leading, tabs) {
9322
+ return leading + ' '.repeat(tabs.length);
9323
+ });
9269
9324
  }
9270
-
9271
- src = src.replace(/^ +$/gm, '');
9272
- var token, i, l, lastToken;
9273
-
9325
+ var token, lastToken, cutSrc, lastParagraphClipped;
9274
9326
  while (src) {
9327
+ if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(function (extTokenizer) {
9328
+ if (token = extTokenizer.call({
9329
+ lexer: _this
9330
+ }, src, tokens)) {
9331
+ src = src.substring(token.raw.length);
9332
+ tokens.push(token);
9333
+ return true;
9334
+ }
9335
+ return false;
9336
+ })) {
9337
+ continue;
9338
+ }
9339
+
9275
9340
  // newline
9276
9341
  if (token = this.tokenizer.space(src)) {
9277
9342
  src = src.substring(token.raw.length);
9278
-
9279
- if (token.type) {
9343
+ if (token.raw.length === 1 && tokens.length > 0) {
9344
+ // if there's a single \n as a spacer, it's terminating the last line,
9345
+ // so move it there so that we don't get unecessary paragraph tags
9346
+ tokens[tokens.length - 1].raw += '\n';
9347
+ } else {
9280
9348
  tokens.push(token);
9281
9349
  }
9282
-
9283
9350
  continue;
9284
- } // code
9285
-
9351
+ }
9286
9352
 
9287
- if (token = this.tokenizer.code(src, tokens)) {
9353
+ // code
9354
+ if (token = this.tokenizer.code(src)) {
9288
9355
  src = src.substring(token.raw.length);
9289
-
9290
- if (token.type) {
9291
- tokens.push(token);
9292
- } else {
9293
- lastToken = tokens[tokens.length - 1];
9356
+ lastToken = tokens[tokens.length - 1];
9357
+ // An indented code block cannot interrupt a paragraph.
9358
+ if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
9294
9359
  lastToken.raw += '\n' + token.raw;
9295
9360
  lastToken.text += '\n' + token.text;
9361
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9362
+ } else {
9363
+ tokens.push(token);
9296
9364
  }
9297
-
9298
9365
  continue;
9299
- } // fences
9300
-
9366
+ }
9301
9367
 
9368
+ // fences
9302
9369
  if (token = this.tokenizer.fences(src)) {
9303
9370
  src = src.substring(token.raw.length);
9304
9371
  tokens.push(token);
9305
9372
  continue;
9306
- } // heading
9307
-
9373
+ }
9308
9374
 
9375
+ // heading
9309
9376
  if (token = this.tokenizer.heading(src)) {
9310
9377
  src = src.substring(token.raw.length);
9311
9378
  tokens.push(token);
9312
9379
  continue;
9313
- } // table no leading pipe (gfm)
9314
-
9315
-
9316
- if (token = this.tokenizer.nptable(src)) {
9317
- src = src.substring(token.raw.length);
9318
- tokens.push(token);
9319
- continue;
9320
- } // hr
9321
-
9380
+ }
9322
9381
 
9382
+ // hr
9323
9383
  if (token = this.tokenizer.hr(src)) {
9324
9384
  src = src.substring(token.raw.length);
9325
9385
  tokens.push(token);
9326
9386
  continue;
9327
- } // blockquote
9328
-
9387
+ }
9329
9388
 
9389
+ // blockquote
9330
9390
  if (token = this.tokenizer.blockquote(src)) {
9331
9391
  src = src.substring(token.raw.length);
9332
- token.tokens = this.blockTokens(token.text, [], top);
9333
9392
  tokens.push(token);
9334
9393
  continue;
9335
- } // list
9336
-
9394
+ }
9337
9395
 
9396
+ // list
9338
9397
  if (token = this.tokenizer.list(src)) {
9339
9398
  src = src.substring(token.raw.length);
9340
- l = token.items.length;
9341
-
9342
- for (i = 0; i < l; i++) {
9343
- token.items[i].tokens = this.blockTokens(token.items[i].text, [], false);
9344
- }
9345
-
9346
9399
  tokens.push(token);
9347
9400
  continue;
9348
- } // html
9349
-
9401
+ }
9350
9402
 
9403
+ // html
9351
9404
  if (token = this.tokenizer.html(src)) {
9352
9405
  src = src.substring(token.raw.length);
9353
9406
  tokens.push(token);
9354
9407
  continue;
9355
- } // def
9356
-
9408
+ }
9357
9409
 
9358
- if (top && (token = this.tokenizer.def(src))) {
9410
+ // def
9411
+ if (token = this.tokenizer.def(src)) {
9359
9412
  src = src.substring(token.raw.length);
9360
-
9361
- if (!this.tokens.links[token.tag]) {
9413
+ lastToken = tokens[tokens.length - 1];
9414
+ if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
9415
+ lastToken.raw += '\n' + token.raw;
9416
+ lastToken.text += '\n' + token.raw;
9417
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9418
+ } else if (!this.tokens.links[token.tag]) {
9362
9419
  this.tokens.links[token.tag] = {
9363
9420
  href: token.href,
9364
9421
  title: token.title
9365
9422
  };
9366
9423
  }
9367
-
9368
9424
  continue;
9369
- } // table (gfm)
9370
-
9425
+ }
9371
9426
 
9427
+ // table (gfm)
9372
9428
  if (token = this.tokenizer.table(src)) {
9373
9429
  src = src.substring(token.raw.length);
9374
9430
  tokens.push(token);
9375
9431
  continue;
9376
- } // lheading
9377
-
9432
+ }
9378
9433
 
9434
+ // lheading
9379
9435
  if (token = this.tokenizer.lheading(src)) {
9380
9436
  src = src.substring(token.raw.length);
9381
9437
  tokens.push(token);
9382
9438
  continue;
9383
- } // top-level paragraph
9384
-
9439
+ }
9385
9440
 
9386
- if (top && (token = this.tokenizer.paragraph(src))) {
9441
+ // top-level paragraph
9442
+ // prevent paragraph consuming extensions by clipping 'src' to extension start
9443
+ cutSrc = src;
9444
+ if (this.options.extensions && this.options.extensions.startBlock) {
9445
+ (function () {
9446
+ var startIndex = Infinity;
9447
+ var tempSrc = src.slice(1);
9448
+ var tempStart = void 0;
9449
+ _this.options.extensions.startBlock.forEach(function (getStartIndex) {
9450
+ tempStart = getStartIndex.call({
9451
+ lexer: this
9452
+ }, tempSrc);
9453
+ if (typeof tempStart === 'number' && tempStart >= 0) {
9454
+ startIndex = Math.min(startIndex, tempStart);
9455
+ }
9456
+ });
9457
+ if (startIndex < Infinity && startIndex >= 0) {
9458
+ cutSrc = src.substring(0, startIndex + 1);
9459
+ }
9460
+ })();
9461
+ }
9462
+ if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
9463
+ lastToken = tokens[tokens.length - 1];
9464
+ if (lastParagraphClipped && lastToken.type === 'paragraph') {
9465
+ lastToken.raw += '\n' + token.raw;
9466
+ lastToken.text += '\n' + token.text;
9467
+ this.inlineQueue.pop();
9468
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9469
+ } else {
9470
+ tokens.push(token);
9471
+ }
9472
+ lastParagraphClipped = cutSrc.length !== src.length;
9387
9473
  src = src.substring(token.raw.length);
9388
- tokens.push(token);
9389
9474
  continue;
9390
- } // text
9391
-
9475
+ }
9392
9476
 
9393
- if (token = this.tokenizer.text(src, tokens)) {
9477
+ // text
9478
+ if (token = this.tokenizer.text(src)) {
9394
9479
  src = src.substring(token.raw.length);
9395
-
9396
- if (token.type) {
9397
- tokens.push(token);
9398
- } else {
9399
- lastToken = tokens[tokens.length - 1];
9480
+ lastToken = tokens[tokens.length - 1];
9481
+ if (lastToken && lastToken.type === 'text') {
9400
9482
  lastToken.raw += '\n' + token.raw;
9401
9483
  lastToken.text += '\n' + token.text;
9484
+ this.inlineQueue.pop();
9485
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
9486
+ } else {
9487
+ tokens.push(token);
9402
9488
  }
9403
-
9404
9489
  continue;
9405
9490
  }
9406
-
9407
9491
  if (src) {
9408
9492
  var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
9409
-
9410
9493
  if (this.options.silent) {
9411
9494
  console.error(errMsg);
9412
9495
  break;
@@ -9415,226 +9498,197 @@ var marked = createCommonjsModule(function (module, exports) {
9415
9498
  }
9416
9499
  }
9417
9500
  }
9418
-
9501
+ this.state.top = true;
9419
9502
  return tokens;
9420
9503
  };
9504
+ _proto.inline = function inline(src, tokens) {
9505
+ if (tokens === void 0) {
9506
+ tokens = [];
9507
+ }
9508
+ this.inlineQueue.push({
9509
+ src: src,
9510
+ tokens: tokens
9511
+ });
9512
+ return tokens;
9513
+ }
9421
9514
 
9422
- _proto.inline = function inline(tokens) {
9423
- var i, j, k, l2, row, token;
9424
- var l = tokens.length;
9515
+ /**
9516
+ * Lexing/Compiling
9517
+ */;
9518
+ _proto.inlineTokens = function inlineTokens(src, tokens) {
9519
+ var _this2 = this;
9520
+ if (tokens === void 0) {
9521
+ tokens = [];
9522
+ }
9523
+ var token, lastToken, cutSrc;
9425
9524
 
9426
- for (i = 0; i < l; i++) {
9427
- token = tokens[i];
9525
+ // String with links masked to avoid interference with em and strong
9526
+ var maskedSrc = src;
9527
+ var match;
9528
+ var keepPrevChar, prevChar;
9428
9529
 
9429
- switch (token.type) {
9430
- case 'paragraph':
9431
- case 'text':
9432
- case 'heading':
9433
- {
9434
- token.tokens = [];
9435
- this.inlineTokens(token.text, token.tokens);
9436
- break;
9437
- }
9438
-
9439
- case 'table':
9440
- {
9441
- token.tokens = {
9442
- header: [],
9443
- cells: []
9444
- }; // header
9445
-
9446
- l2 = token.header.length;
9447
-
9448
- for (j = 0; j < l2; j++) {
9449
- token.tokens.header[j] = [];
9450
- this.inlineTokens(token.header[j], token.tokens.header[j]);
9451
- } // cells
9452
-
9453
-
9454
- l2 = token.cells.length;
9455
-
9456
- for (j = 0; j < l2; j++) {
9457
- row = token.cells[j];
9458
- token.tokens.cells[j] = [];
9459
-
9460
- for (k = 0; k < row.length; k++) {
9461
- token.tokens.cells[j][k] = [];
9462
- this.inlineTokens(row[k], token.tokens.cells[j][k]);
9463
- }
9464
- }
9465
-
9466
- break;
9467
- }
9468
-
9469
- case 'blockquote':
9470
- {
9471
- this.inline(token.tokens);
9472
- break;
9473
- }
9474
-
9475
- case 'list':
9476
- {
9477
- l2 = token.items.length;
9478
-
9479
- for (j = 0; j < l2; j++) {
9480
- this.inline(token.items[j].tokens);
9481
- }
9482
-
9483
- break;
9530
+ // Mask out reflinks
9531
+ if (this.tokens.links) {
9532
+ var links = Object.keys(this.tokens.links);
9533
+ if (links.length > 0) {
9534
+ while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
9535
+ if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
9536
+ maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
9484
9537
  }
9538
+ }
9485
9539
  }
9486
9540
  }
9487
-
9488
- return tokens;
9489
- }
9490
- /**
9491
- * Lexing/Compiling
9492
- */
9493
- ;
9494
-
9495
- _proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock, prevChar) {
9496
- if (tokens === void 0) {
9497
- tokens = [];
9498
- }
9499
-
9500
- if (inLink === void 0) {
9501
- inLink = false;
9502
- }
9503
-
9504
- if (inRawBlock === void 0) {
9505
- inRawBlock = false;
9541
+ // Mask out other blocks
9542
+ while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
9543
+ maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
9506
9544
  }
9507
9545
 
9508
- if (prevChar === void 0) {
9509
- prevChar = '';
9546
+ // Mask out escaped em & strong delimiters
9547
+ while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
9548
+ maskedSrc = maskedSrc.slice(0, match.index + match[0].length - 2) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
9549
+ this.tokenizer.rules.inline.escapedEmSt.lastIndex--;
9510
9550
  }
9551
+ while (src) {
9552
+ if (!keepPrevChar) {
9553
+ prevChar = '';
9554
+ }
9555
+ keepPrevChar = false;
9511
9556
 
9512
- var token; // String with links masked to avoid interference with em and strong
9513
-
9514
- var maskedSrc = src;
9515
- var match; // Mask out reflinks
9516
-
9517
- if (this.tokens.links) {
9518
- var links = Object.keys(this.tokens.links);
9519
-
9520
- if (links.length > 0) {
9521
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
9522
- if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
9523
- maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
9524
- }
9557
+ // extensions
9558
+ if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(function (extTokenizer) {
9559
+ if (token = extTokenizer.call({
9560
+ lexer: _this2
9561
+ }, src, tokens)) {
9562
+ src = src.substring(token.raw.length);
9563
+ tokens.push(token);
9564
+ return true;
9525
9565
  }
9566
+ return false;
9567
+ })) {
9568
+ continue;
9526
9569
  }
9527
- } // Mask out other blocks
9528
-
9529
-
9530
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
9531
- maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
9532
- }
9533
9570
 
9534
- while (src) {
9535
9571
  // escape
9536
9572
  if (token = this.tokenizer.escape(src)) {
9537
9573
  src = src.substring(token.raw.length);
9538
9574
  tokens.push(token);
9539
9575
  continue;
9540
- } // tag
9541
-
9576
+ }
9542
9577
 
9543
- if (token = this.tokenizer.tag(src, inLink, inRawBlock)) {
9578
+ // tag
9579
+ if (token = this.tokenizer.tag(src)) {
9544
9580
  src = src.substring(token.raw.length);
9545
- inLink = token.inLink;
9546
- inRawBlock = token.inRawBlock;
9547
- tokens.push(token);
9581
+ lastToken = tokens[tokens.length - 1];
9582
+ if (lastToken && token.type === 'text' && lastToken.type === 'text') {
9583
+ lastToken.raw += token.raw;
9584
+ lastToken.text += token.text;
9585
+ } else {
9586
+ tokens.push(token);
9587
+ }
9548
9588
  continue;
9549
- } // link
9550
-
9589
+ }
9551
9590
 
9591
+ // link
9552
9592
  if (token = this.tokenizer.link(src)) {
9553
9593
  src = src.substring(token.raw.length);
9554
-
9555
- if (token.type === 'link') {
9556
- token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
9557
- }
9558
-
9559
9594
  tokens.push(token);
9560
9595
  continue;
9561
- } // reflink, nolink
9562
-
9596
+ }
9563
9597
 
9598
+ // reflink, nolink
9564
9599
  if (token = this.tokenizer.reflink(src, this.tokens.links)) {
9565
9600
  src = src.substring(token.raw.length);
9566
-
9567
- if (token.type === 'link') {
9568
- token.tokens = this.inlineTokens(token.text, [], true, inRawBlock);
9601
+ lastToken = tokens[tokens.length - 1];
9602
+ if (lastToken && token.type === 'text' && lastToken.type === 'text') {
9603
+ lastToken.raw += token.raw;
9604
+ lastToken.text += token.text;
9605
+ } else {
9606
+ tokens.push(token);
9569
9607
  }
9570
-
9571
- tokens.push(token);
9572
9608
  continue;
9573
- } // strong
9574
-
9575
-
9576
- if (token = this.tokenizer.strong(src, maskedSrc, prevChar)) {
9577
- src = src.substring(token.raw.length);
9578
- token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
9579
- tokens.push(token);
9580
- continue;
9581
- } // em
9582
-
9609
+ }
9583
9610
 
9584
- if (token = this.tokenizer.em(src, maskedSrc, prevChar)) {
9611
+ // em & strong
9612
+ if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
9585
9613
  src = src.substring(token.raw.length);
9586
- token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
9587
9614
  tokens.push(token);
9588
9615
  continue;
9589
- } // code
9590
-
9616
+ }
9591
9617
 
9618
+ // code
9592
9619
  if (token = this.tokenizer.codespan(src)) {
9593
9620
  src = src.substring(token.raw.length);
9594
9621
  tokens.push(token);
9595
9622
  continue;
9596
- } // br
9597
-
9623
+ }
9598
9624
 
9625
+ // br
9599
9626
  if (token = this.tokenizer.br(src)) {
9600
9627
  src = src.substring(token.raw.length);
9601
9628
  tokens.push(token);
9602
9629
  continue;
9603
- } // del (gfm)
9604
-
9630
+ }
9605
9631
 
9632
+ // del (gfm)
9606
9633
  if (token = this.tokenizer.del(src)) {
9607
9634
  src = src.substring(token.raw.length);
9608
- token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
9609
9635
  tokens.push(token);
9610
9636
  continue;
9611
- } // autolink
9612
-
9637
+ }
9613
9638
 
9639
+ // autolink
9614
9640
  if (token = this.tokenizer.autolink(src, mangle)) {
9615
9641
  src = src.substring(token.raw.length);
9616
9642
  tokens.push(token);
9617
9643
  continue;
9618
- } // url (gfm)
9619
-
9644
+ }
9620
9645
 
9621
- if (!inLink && (token = this.tokenizer.url(src, mangle))) {
9646
+ // url (gfm)
9647
+ if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
9622
9648
  src = src.substring(token.raw.length);
9623
9649
  tokens.push(token);
9624
9650
  continue;
9625
- } // text
9626
-
9651
+ }
9627
9652
 
9628
- if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
9653
+ // text
9654
+ // prevent inlineText consuming extensions by clipping 'src' to extension start
9655
+ cutSrc = src;
9656
+ if (this.options.extensions && this.options.extensions.startInline) {
9657
+ (function () {
9658
+ var startIndex = Infinity;
9659
+ var tempSrc = src.slice(1);
9660
+ var tempStart = void 0;
9661
+ _this2.options.extensions.startInline.forEach(function (getStartIndex) {
9662
+ tempStart = getStartIndex.call({
9663
+ lexer: this
9664
+ }, tempSrc);
9665
+ if (typeof tempStart === 'number' && tempStart >= 0) {
9666
+ startIndex = Math.min(startIndex, tempStart);
9667
+ }
9668
+ });
9669
+ if (startIndex < Infinity && startIndex >= 0) {
9670
+ cutSrc = src.substring(0, startIndex + 1);
9671
+ }
9672
+ })();
9673
+ }
9674
+ if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
9629
9675
  src = src.substring(token.raw.length);
9630
- prevChar = token.raw.slice(-1);
9631
- tokens.push(token);
9676
+ if (token.raw.slice(-1) !== '_') {
9677
+ // Track prevChar before string of ____ started
9678
+ prevChar = token.raw.slice(-1);
9679
+ }
9680
+ keepPrevChar = true;
9681
+ lastToken = tokens[tokens.length - 1];
9682
+ if (lastToken && lastToken.type === 'text') {
9683
+ lastToken.raw += token.raw;
9684
+ lastToken.text += token.text;
9685
+ } else {
9686
+ tokens.push(token);
9687
+ }
9632
9688
  continue;
9633
9689
  }
9634
-
9635
9690
  if (src) {
9636
9691
  var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
9637
-
9638
9692
  if (this.options.silent) {
9639
9693
  console.error(errMsg);
9640
9694
  break;
@@ -9643,169 +9697,186 @@ var marked = createCommonjsModule(function (module, exports) {
9643
9697
  }
9644
9698
  }
9645
9699
  }
9646
-
9647
9700
  return tokens;
9648
9701
  };
9649
-
9650
9702
  _createClass(Lexer, null, [{
9651
9703
  key: "rules",
9652
9704
  get: function get() {
9653
9705
  return {
9654
- block: block$1,
9655
- inline: inline$1
9706
+ block: block,
9707
+ inline: inline
9656
9708
  };
9657
9709
  }
9658
9710
  }]);
9659
-
9660
9711
  return Lexer;
9661
9712
  }();
9662
9713
 
9663
- var defaults$3 = defaults.defaults;
9664
- var cleanUrl$1 = helpers.cleanUrl,
9665
- escape$1 = helpers.escape;
9666
9714
  /**
9667
9715
  * Renderer
9668
9716
  */
9669
-
9670
- var Renderer_1 = /*#__PURE__*/function () {
9717
+ var Renderer = /*#__PURE__*/function () {
9671
9718
  function Renderer(options) {
9672
- this.options = options || defaults$3;
9719
+ this.options = options || exports.defaults;
9673
9720
  }
9674
-
9675
9721
  var _proto = Renderer.prototype;
9676
-
9677
9722
  _proto.code = function code(_code, infostring, escaped) {
9678
9723
  var lang = (infostring || '').match(/\S*/)[0];
9679
-
9680
9724
  if (this.options.highlight) {
9681
9725
  var out = this.options.highlight(_code, lang);
9682
-
9683
9726
  if (out != null && out !== _code) {
9684
9727
  escaped = true;
9685
9728
  _code = out;
9686
9729
  }
9687
9730
  }
9688
-
9731
+ _code = _code.replace(/\n$/, '') + '\n';
9689
9732
  if (!lang) {
9690
- return '<pre><code>' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>\n';
9733
+ return '<pre><code>' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
9691
9734
  }
9735
+ return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ? _code : escape(_code, true)) + '</code></pre>\n';
9736
+ }
9692
9737
 
9693
- return '<pre><code class="' + this.options.langPrefix + escape$1(lang, true) + '">' + (escaped ? _code : escape$1(_code, true)) + '</code></pre>\n';
9694
- };
9695
-
9738
+ /**
9739
+ * @param {string} quote
9740
+ */;
9696
9741
  _proto.blockquote = function blockquote(quote) {
9697
- return '<blockquote>\n' + quote + '</blockquote>\n';
9742
+ return "<blockquote>\n" + quote + "</blockquote>\n";
9698
9743
  };
9699
-
9700
9744
  _proto.html = function html(_html) {
9701
9745
  return _html;
9702
- };
9746
+ }
9703
9747
 
9748
+ /**
9749
+ * @param {string} text
9750
+ * @param {string} level
9751
+ * @param {string} raw
9752
+ * @param {any} slugger
9753
+ */;
9704
9754
  _proto.heading = function heading(text, level, raw, slugger) {
9705
9755
  if (this.options.headerIds) {
9706
- return '<h' + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + '</h' + level + '>\n';
9707
- } // ignore IDs
9708
-
9756
+ var id = this.options.headerPrefix + slugger.slug(raw);
9757
+ return "<h" + level + " id=\"" + id + "\">" + text + "</h" + level + ">\n";
9758
+ }
9709
9759
 
9710
- return '<h' + level + '>' + text + '</h' + level + '>\n';
9760
+ // ignore IDs
9761
+ return "<h" + level + ">" + text + "</h" + level + ">\n";
9711
9762
  };
9712
-
9713
9763
  _proto.hr = function hr() {
9714
9764
  return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
9715
9765
  };
9716
-
9717
9766
  _proto.list = function list(body, ordered, start) {
9718
9767
  var type = ordered ? 'ol' : 'ul',
9719
- startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
9768
+ startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
9720
9769
  return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
9721
- };
9770
+ }
9722
9771
 
9772
+ /**
9773
+ * @param {string} text
9774
+ */;
9723
9775
  _proto.listitem = function listitem(text) {
9724
- return '<li>' + text + '</li>\n';
9776
+ return "<li>" + text + "</li>\n";
9725
9777
  };
9726
-
9727
9778
  _proto.checkbox = function checkbox(checked) {
9728
9779
  return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox"' + (this.options.xhtml ? ' /' : '') + '> ';
9729
- };
9780
+ }
9730
9781
 
9782
+ /**
9783
+ * @param {string} text
9784
+ */;
9731
9785
  _proto.paragraph = function paragraph(text) {
9732
- return '<p>' + text + '</p>\n';
9733
- };
9786
+ return "<p>" + text + "</p>\n";
9787
+ }
9734
9788
 
9789
+ /**
9790
+ * @param {string} header
9791
+ * @param {string} body
9792
+ */;
9735
9793
  _proto.table = function table(header, body) {
9736
- if (body) body = '<tbody>' + body + '</tbody>';
9794
+ if (body) body = "<tbody>" + body + "</tbody>";
9737
9795
  return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
9738
- };
9796
+ }
9739
9797
 
9798
+ /**
9799
+ * @param {string} content
9800
+ */;
9740
9801
  _proto.tablerow = function tablerow(content) {
9741
- return '<tr>\n' + content + '</tr>\n';
9802
+ return "<tr>\n" + content + "</tr>\n";
9742
9803
  };
9743
-
9744
9804
  _proto.tablecell = function tablecell(content, flags) {
9745
9805
  var type = flags.header ? 'th' : 'td';
9746
- var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
9747
- return tag + content + '</' + type + '>\n';
9748
- } // span level renderer
9749
- ;
9806
+ var tag = flags.align ? "<" + type + " align=\"" + flags.align + "\">" : "<" + type + ">";
9807
+ return tag + content + ("</" + type + ">\n");
9808
+ }
9750
9809
 
9810
+ /**
9811
+ * span level renderer
9812
+ * @param {string} text
9813
+ */;
9751
9814
  _proto.strong = function strong(text) {
9752
- return '<strong>' + text + '</strong>';
9753
- };
9815
+ return "<strong>" + text + "</strong>";
9816
+ }
9754
9817
 
9818
+ /**
9819
+ * @param {string} text
9820
+ */;
9755
9821
  _proto.em = function em(text) {
9756
- return '<em>' + text + '</em>';
9757
- };
9822
+ return "<em>" + text + "</em>";
9823
+ }
9758
9824
 
9825
+ /**
9826
+ * @param {string} text
9827
+ */;
9759
9828
  _proto.codespan = function codespan(text) {
9760
- return '<code>' + text + '</code>';
9829
+ return "<code>" + text + "</code>";
9761
9830
  };
9762
-
9763
9831
  _proto.br = function br() {
9764
9832
  return this.options.xhtml ? '<br/>' : '<br>';
9765
- };
9833
+ }
9766
9834
 
9835
+ /**
9836
+ * @param {string} text
9837
+ */;
9767
9838
  _proto.del = function del(text) {
9768
- return '<del>' + text + '</del>';
9769
- };
9839
+ return "<del>" + text + "</del>";
9840
+ }
9770
9841
 
9842
+ /**
9843
+ * @param {string} href
9844
+ * @param {string} title
9845
+ * @param {string} text
9846
+ */;
9771
9847
  _proto.link = function link(href, title, text) {
9772
- href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
9773
-
9848
+ href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
9774
9849
  if (href === null) {
9775
9850
  return text;
9776
9851
  }
9777
-
9778
- var out = '<a href="' + escape$1(href) + '"';
9779
-
9852
+ var out = '<a href="' + href + '"';
9780
9853
  if (title) {
9781
9854
  out += ' title="' + title + '"';
9782
9855
  }
9783
-
9784
9856
  out += '>' + text + '</a>';
9785
9857
  return out;
9786
- };
9858
+ }
9787
9859
 
9860
+ /**
9861
+ * @param {string} href
9862
+ * @param {string} title
9863
+ * @param {string} text
9864
+ */;
9788
9865
  _proto.image = function image(href, title, text) {
9789
- href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
9790
-
9866
+ href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
9791
9867
  if (href === null) {
9792
9868
  return text;
9793
9869
  }
9794
-
9795
- var out = '<img src="' + href + '" alt="' + text + '"';
9796
-
9870
+ var out = "<img src=\"" + href + "\" alt=\"" + text + "\"";
9797
9871
  if (title) {
9798
- out += ' title="' + title + '"';
9872
+ out += " title=\"" + title + "\"";
9799
9873
  }
9800
-
9801
9874
  out += this.options.xhtml ? '/>' : '>';
9802
9875
  return out;
9803
9876
  };
9804
-
9805
9877
  _proto.text = function text(_text) {
9806
9878
  return _text;
9807
9879
  };
9808
-
9809
9880
  return Renderer;
9810
9881
  }();
9811
9882
 
@@ -9813,214 +9884,226 @@ var marked = createCommonjsModule(function (module, exports) {
9813
9884
  * TextRenderer
9814
9885
  * returns only the textual part of the token
9815
9886
  */
9816
- var TextRenderer_1 = /*#__PURE__*/function () {
9887
+ var TextRenderer = /*#__PURE__*/function () {
9817
9888
  function TextRenderer() {}
9818
-
9819
9889
  var _proto = TextRenderer.prototype;
9820
-
9821
9890
  // no need for block level renderers
9822
9891
  _proto.strong = function strong(text) {
9823
9892
  return text;
9824
9893
  };
9825
-
9826
9894
  _proto.em = function em(text) {
9827
9895
  return text;
9828
9896
  };
9829
-
9830
9897
  _proto.codespan = function codespan(text) {
9831
9898
  return text;
9832
9899
  };
9833
-
9834
9900
  _proto.del = function del(text) {
9835
9901
  return text;
9836
9902
  };
9837
-
9838
9903
  _proto.html = function html(text) {
9839
9904
  return text;
9840
9905
  };
9841
-
9842
9906
  _proto.text = function text(_text) {
9843
9907
  return _text;
9844
9908
  };
9845
-
9846
9909
  _proto.link = function link(href, title, text) {
9847
9910
  return '' + text;
9848
9911
  };
9849
-
9850
9912
  _proto.image = function image(href, title, text) {
9851
9913
  return '' + text;
9852
9914
  };
9853
-
9854
9915
  _proto.br = function br() {
9855
9916
  return '';
9856
9917
  };
9857
-
9858
9918
  return TextRenderer;
9859
9919
  }();
9860
9920
 
9861
9921
  /**
9862
9922
  * Slugger generates header id
9863
9923
  */
9864
- var Slugger_1 = /*#__PURE__*/function () {
9924
+ var Slugger = /*#__PURE__*/function () {
9865
9925
  function Slugger() {
9866
9926
  this.seen = {};
9867
9927
  }
9928
+
9868
9929
  /**
9869
- * Convert string to unique id
9930
+ * @param {string} value
9870
9931
  */
9871
-
9872
-
9873
9932
  var _proto = Slugger.prototype;
9874
-
9875
- _proto.slug = function slug(value) {
9876
- var slug = value.toLowerCase().trim() // remove html tags
9877
- .replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
9933
+ _proto.serialize = function serialize(value) {
9934
+ return value.toLowerCase().trim()
9935
+ // remove html tags
9936
+ .replace(/<[!\/a-z].*?>/ig, '')
9937
+ // remove unwanted chars
9878
9938
  .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
9939
+ }
9879
9940
 
9941
+ /**
9942
+ * Finds the next safe (unique) slug to use
9943
+ * @param {string} originalSlug
9944
+ * @param {boolean} isDryRun
9945
+ */;
9946
+ _proto.getNextSafeSlug = function getNextSafeSlug(originalSlug, isDryRun) {
9947
+ var slug = originalSlug;
9948
+ var occurenceAccumulator = 0;
9880
9949
  if (this.seen.hasOwnProperty(slug)) {
9881
- var originalSlug = slug;
9882
-
9950
+ occurenceAccumulator = this.seen[originalSlug];
9883
9951
  do {
9884
- this.seen[originalSlug]++;
9885
- slug = originalSlug + '-' + this.seen[originalSlug];
9952
+ occurenceAccumulator++;
9953
+ slug = originalSlug + '-' + occurenceAccumulator;
9886
9954
  } while (this.seen.hasOwnProperty(slug));
9887
9955
  }
9888
-
9889
- this.seen[slug] = 0;
9956
+ if (!isDryRun) {
9957
+ this.seen[originalSlug] = occurenceAccumulator;
9958
+ this.seen[slug] = 0;
9959
+ }
9890
9960
  return slug;
9891
- };
9961
+ }
9892
9962
 
9963
+ /**
9964
+ * Convert string to unique id
9965
+ * @param {object} [options]
9966
+ * @param {boolean} [options.dryrun] Generates the next unique slug without
9967
+ * updating the internal accumulator.
9968
+ */;
9969
+ _proto.slug = function slug(value, options) {
9970
+ if (options === void 0) {
9971
+ options = {};
9972
+ }
9973
+ var slug = this.serialize(value);
9974
+ return this.getNextSafeSlug(slug, options.dryrun);
9975
+ };
9893
9976
  return Slugger;
9894
9977
  }();
9895
9978
 
9896
- var defaults$4 = defaults.defaults;
9897
- var unescape$1 = helpers.unescape;
9898
9979
  /**
9899
9980
  * Parsing & Compiling
9900
9981
  */
9901
-
9902
- var Parser_1 = /*#__PURE__*/function () {
9982
+ var Parser = /*#__PURE__*/function () {
9903
9983
  function Parser(options) {
9904
- this.options = options || defaults$4;
9905
- this.options.renderer = this.options.renderer || new Renderer_1();
9984
+ this.options = options || exports.defaults;
9985
+ this.options.renderer = this.options.renderer || new Renderer();
9906
9986
  this.renderer = this.options.renderer;
9907
9987
  this.renderer.options = this.options;
9908
- this.textRenderer = new TextRenderer_1();
9909
- this.slugger = new Slugger_1();
9988
+ this.textRenderer = new TextRenderer();
9989
+ this.slugger = new Slugger();
9910
9990
  }
9991
+
9911
9992
  /**
9912
9993
  * Static Parse Method
9913
9994
  */
9914
-
9915
-
9916
9995
  Parser.parse = function parse(tokens, options) {
9917
9996
  var parser = new Parser(options);
9918
9997
  return parser.parse(tokens);
9919
9998
  }
9999
+
9920
10000
  /**
9921
- * Parse Loop
9922
- */
9923
- ;
10001
+ * Static Parse Inline Method
10002
+ */;
10003
+ Parser.parseInline = function parseInline(tokens, options) {
10004
+ var parser = new Parser(options);
10005
+ return parser.parseInline(tokens);
10006
+ }
9924
10007
 
10008
+ /**
10009
+ * Parse Loop
10010
+ */;
9925
10011
  var _proto = Parser.prototype;
9926
-
9927
10012
  _proto.parse = function parse(tokens, top) {
9928
10013
  if (top === void 0) {
9929
10014
  top = true;
9930
10015
  }
9931
-
9932
10016
  var out = '',
9933
- i,
9934
- j,
9935
- k,
9936
- l2,
9937
- l3,
9938
- row,
9939
- cell,
9940
- header,
9941
- body,
9942
- token,
9943
- ordered,
9944
- start,
9945
- loose,
9946
- itemBody,
9947
- item,
9948
- checked,
9949
- task,
9950
- checkbox;
10017
+ i,
10018
+ j,
10019
+ k,
10020
+ l2,
10021
+ l3,
10022
+ row,
10023
+ cell,
10024
+ header,
10025
+ body,
10026
+ token,
10027
+ ordered,
10028
+ start,
10029
+ loose,
10030
+ itemBody,
10031
+ item,
10032
+ checked,
10033
+ task,
10034
+ checkbox,
10035
+ ret;
9951
10036
  var l = tokens.length;
9952
-
9953
10037
  for (i = 0; i < l; i++) {
9954
10038
  token = tokens[i];
9955
10039
 
10040
+ // Run any renderer extensions
10041
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
10042
+ ret = this.options.extensions.renderers[token.type].call({
10043
+ parser: this
10044
+ }, token);
10045
+ if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
10046
+ out += ret || '';
10047
+ continue;
10048
+ }
10049
+ }
9956
10050
  switch (token.type) {
9957
10051
  case 'space':
9958
10052
  {
9959
10053
  continue;
9960
10054
  }
9961
-
9962
10055
  case 'hr':
9963
10056
  {
9964
10057
  out += this.renderer.hr();
9965
10058
  continue;
9966
10059
  }
9967
-
9968
10060
  case 'heading':
9969
10061
  {
9970
- out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape$1(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
10062
+ out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
9971
10063
  continue;
9972
10064
  }
9973
-
9974
10065
  case 'code':
9975
10066
  {
9976
10067
  out += this.renderer.code(token.text, token.lang, token.escaped);
9977
10068
  continue;
9978
10069
  }
9979
-
9980
10070
  case 'table':
9981
10071
  {
9982
- header = ''; // header
10072
+ header = '';
9983
10073
 
10074
+ // header
9984
10075
  cell = '';
9985
10076
  l2 = token.header.length;
9986
-
9987
10077
  for (j = 0; j < l2; j++) {
9988
- cell += this.renderer.tablecell(this.parseInline(token.tokens.header[j]), {
10078
+ cell += this.renderer.tablecell(this.parseInline(token.header[j].tokens), {
9989
10079
  header: true,
9990
10080
  align: token.align[j]
9991
10081
  });
9992
10082
  }
9993
-
9994
10083
  header += this.renderer.tablerow(cell);
9995
10084
  body = '';
9996
- l2 = token.cells.length;
9997
-
10085
+ l2 = token.rows.length;
9998
10086
  for (j = 0; j < l2; j++) {
9999
- row = token.tokens.cells[j];
10087
+ row = token.rows[j];
10000
10088
  cell = '';
10001
10089
  l3 = row.length;
10002
-
10003
10090
  for (k = 0; k < l3; k++) {
10004
- cell += this.renderer.tablecell(this.parseInline(row[k]), {
10091
+ cell += this.renderer.tablecell(this.parseInline(row[k].tokens), {
10005
10092
  header: false,
10006
10093
  align: token.align[k]
10007
10094
  });
10008
10095
  }
10009
-
10010
10096
  body += this.renderer.tablerow(cell);
10011
10097
  }
10012
-
10013
10098
  out += this.renderer.table(header, body);
10014
10099
  continue;
10015
10100
  }
10016
-
10017
10101
  case 'blockquote':
10018
10102
  {
10019
10103
  body = this.parse(token.tokens);
10020
10104
  out += this.renderer.blockquote(body);
10021
10105
  continue;
10022
10106
  }
10023
-
10024
10107
  case 'list':
10025
10108
  {
10026
10109
  ordered = token.ordered;
@@ -10028,20 +10111,16 @@ var marked = createCommonjsModule(function (module, exports) {
10028
10111
  loose = token.loose;
10029
10112
  l2 = token.items.length;
10030
10113
  body = '';
10031
-
10032
10114
  for (j = 0; j < l2; j++) {
10033
10115
  item = token.items[j];
10034
10116
  checked = item.checked;
10035
10117
  task = item.task;
10036
10118
  itemBody = '';
10037
-
10038
10119
  if (item.task) {
10039
10120
  checkbox = this.renderer.checkbox(checked);
10040
-
10041
10121
  if (loose) {
10042
- if (item.tokens.length > 0 && item.tokens[0].type === 'text') {
10122
+ if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
10043
10123
  item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
10044
-
10045
10124
  if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
10046
10125
  item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
10047
10126
  }
@@ -10055,45 +10134,36 @@ var marked = createCommonjsModule(function (module, exports) {
10055
10134
  itemBody += checkbox;
10056
10135
  }
10057
10136
  }
10058
-
10059
10137
  itemBody += this.parse(item.tokens, loose);
10060
10138
  body += this.renderer.listitem(itemBody, task, checked);
10061
10139
  }
10062
-
10063
10140
  out += this.renderer.list(body, ordered, start);
10064
10141
  continue;
10065
10142
  }
10066
-
10067
10143
  case 'html':
10068
10144
  {
10069
10145
  // TODO parse inline content if parameter markdown=1
10070
10146
  out += this.renderer.html(token.text);
10071
10147
  continue;
10072
10148
  }
10073
-
10074
10149
  case 'paragraph':
10075
10150
  {
10076
10151
  out += this.renderer.paragraph(this.parseInline(token.tokens));
10077
10152
  continue;
10078
10153
  }
10079
-
10080
10154
  case 'text':
10081
10155
  {
10082
10156
  body = token.tokens ? this.parseInline(token.tokens) : token.text;
10083
-
10084
10157
  while (i + 1 < l && tokens[i + 1].type === 'text') {
10085
10158
  token = tokens[++i];
10086
10159
  body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
10087
10160
  }
10088
-
10089
10161
  out += top ? this.renderer.paragraph(body) : body;
10090
10162
  continue;
10091
10163
  }
10092
-
10093
10164
  default:
10094
10165
  {
10095
10166
  var errMsg = 'Token with "' + token.type + '" type was not found.';
10096
-
10097
10167
  if (this.options.silent) {
10098
10168
  console.error(errMsg);
10099
10169
  return;
@@ -10103,89 +10173,86 @@ var marked = createCommonjsModule(function (module, exports) {
10103
10173
  }
10104
10174
  }
10105
10175
  }
10106
-
10107
10176
  return out;
10108
10177
  }
10178
+
10109
10179
  /**
10110
10180
  * Parse Inline Tokens
10111
- */
10112
- ;
10113
-
10181
+ */;
10114
10182
  _proto.parseInline = function parseInline(tokens, renderer) {
10115
10183
  renderer = renderer || this.renderer;
10116
10184
  var out = '',
10117
- i,
10118
- token;
10185
+ i,
10186
+ token,
10187
+ ret;
10119
10188
  var l = tokens.length;
10120
-
10121
10189
  for (i = 0; i < l; i++) {
10122
10190
  token = tokens[i];
10123
10191
 
10192
+ // Run any renderer extensions
10193
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
10194
+ ret = this.options.extensions.renderers[token.type].call({
10195
+ parser: this
10196
+ }, token);
10197
+ if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
10198
+ out += ret || '';
10199
+ continue;
10200
+ }
10201
+ }
10124
10202
  switch (token.type) {
10125
10203
  case 'escape':
10126
10204
  {
10127
10205
  out += renderer.text(token.text);
10128
10206
  break;
10129
10207
  }
10130
-
10131
10208
  case 'html':
10132
10209
  {
10133
10210
  out += renderer.html(token.text);
10134
10211
  break;
10135
10212
  }
10136
-
10137
10213
  case 'link':
10138
10214
  {
10139
10215
  out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
10140
10216
  break;
10141
10217
  }
10142
-
10143
10218
  case 'image':
10144
10219
  {
10145
10220
  out += renderer.image(token.href, token.title, token.text);
10146
10221
  break;
10147
10222
  }
10148
-
10149
10223
  case 'strong':
10150
10224
  {
10151
10225
  out += renderer.strong(this.parseInline(token.tokens, renderer));
10152
10226
  break;
10153
10227
  }
10154
-
10155
10228
  case 'em':
10156
10229
  {
10157
10230
  out += renderer.em(this.parseInline(token.tokens, renderer));
10158
10231
  break;
10159
10232
  }
10160
-
10161
10233
  case 'codespan':
10162
10234
  {
10163
10235
  out += renderer.codespan(token.text);
10164
10236
  break;
10165
10237
  }
10166
-
10167
10238
  case 'br':
10168
10239
  {
10169
10240
  out += renderer.br();
10170
10241
  break;
10171
10242
  }
10172
-
10173
10243
  case 'del':
10174
10244
  {
10175
10245
  out += renderer.del(this.parseInline(token.tokens, renderer));
10176
10246
  break;
10177
10247
  }
10178
-
10179
10248
  case 'text':
10180
10249
  {
10181
10250
  out += renderer.text(token.text);
10182
10251
  break;
10183
10252
  }
10184
-
10185
10253
  default:
10186
10254
  {
10187
10255
  var errMsg = 'Token with "' + token.type + '" type was not found.';
10188
-
10189
10256
  if (this.options.silent) {
10190
10257
  console.error(errMsg);
10191
10258
  return;
@@ -10195,280 +10262,464 @@ var marked = createCommonjsModule(function (module, exports) {
10195
10262
  }
10196
10263
  }
10197
10264
  }
10198
-
10199
10265
  return out;
10200
10266
  };
10201
-
10202
10267
  return Parser;
10203
10268
  }();
10204
10269
 
10205
- var merge$2 = helpers.merge,
10206
- checkSanitizeDeprecation$1 = helpers.checkSanitizeDeprecation,
10207
- escape$2 = helpers.escape;
10208
- var getDefaults = defaults.getDefaults,
10209
- changeDefaults = defaults.changeDefaults,
10210
- defaults$5 = defaults.defaults;
10211
- /**
10212
- * Marked
10213
- */
10214
-
10215
- function marked(src, opt, callback) {
10216
- // throw error in case of non string input
10217
- if (typeof src === 'undefined' || src === null) {
10218
- throw new Error('marked(): input parameter is undefined or null');
10270
+ var Hooks = /*#__PURE__*/function () {
10271
+ function Hooks(options) {
10272
+ this.options = options || exports.defaults;
10219
10273
  }
10220
-
10221
- if (typeof src !== 'string') {
10222
- throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
10223
- }
10224
-
10225
- if (typeof opt === 'function') {
10226
- callback = opt;
10227
- opt = null;
10274
+ var _proto = Hooks.prototype;
10275
+ /**
10276
+ * Process markdown before marked
10277
+ */
10278
+ _proto.preprocess = function preprocess(markdown) {
10279
+ return markdown;
10228
10280
  }
10229
10281
 
10230
- opt = merge$2({}, marked.defaults, opt || {});
10231
- checkSanitizeDeprecation$1(opt);
10232
-
10233
- if (callback) {
10234
- var highlight = opt.highlight;
10235
- var tokens;
10282
+ /**
10283
+ * Process HTML after marked is finished
10284
+ */;
10285
+ _proto.postprocess = function postprocess(html) {
10286
+ return html;
10287
+ };
10288
+ return Hooks;
10289
+ }();
10290
+ Hooks.passThroughHooks = new Set(['preprocess', 'postprocess']);
10236
10291
 
10237
- try {
10238
- tokens = Lexer_1.lex(src, opt);
10239
- } catch (e) {
10240
- return callback(e);
10292
+ function onError(silent, async, callback) {
10293
+ return function (e) {
10294
+ e.message += '\nPlease report this to https://github.com/markedjs/marked.';
10295
+ if (silent) {
10296
+ var msg = '<p>An error occurred:</p><pre>' + escape(e.message + '', true) + '</pre>';
10297
+ if (async) {
10298
+ return Promise.resolve(msg);
10299
+ }
10300
+ if (callback) {
10301
+ callback(null, msg);
10302
+ return;
10303
+ }
10304
+ return msg;
10241
10305
  }
10306
+ if (async) {
10307
+ return Promise.reject(e);
10308
+ }
10309
+ if (callback) {
10310
+ callback(e);
10311
+ return;
10312
+ }
10313
+ throw e;
10314
+ };
10315
+ }
10316
+ function parseMarkdown(lexer, parser) {
10317
+ return function (src, opt, callback) {
10318
+ if (typeof opt === 'function') {
10319
+ callback = opt;
10320
+ opt = null;
10321
+ }
10322
+ var origOpt = _extends({}, opt);
10323
+ opt = _extends({}, marked.defaults, origOpt);
10324
+ var throwError = onError(opt.silent, opt.async, callback);
10242
10325
 
10243
- var done = function done(err) {
10244
- var out;
10245
-
10246
- if (!err) {
10247
- try {
10248
- out = Parser_1.parse(tokens, opt);
10249
- } catch (e) {
10250
- err = e;
10326
+ // throw error in case of non string input
10327
+ if (typeof src === 'undefined' || src === null) {
10328
+ return throwError(new Error('marked(): input parameter is undefined or null'));
10329
+ }
10330
+ if (typeof src !== 'string') {
10331
+ return throwError(new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'));
10332
+ }
10333
+ checkSanitizeDeprecation(opt);
10334
+ if (opt.hooks) {
10335
+ opt.hooks.options = opt;
10336
+ }
10337
+ if (callback) {
10338
+ var highlight = opt.highlight;
10339
+ var tokens;
10340
+ try {
10341
+ if (opt.hooks) {
10342
+ src = opt.hooks.preprocess(src);
10251
10343
  }
10344
+ tokens = lexer(src, opt);
10345
+ } catch (e) {
10346
+ return throwError(e);
10252
10347
  }
10253
-
10254
- opt.highlight = highlight;
10255
- return err ? callback(err) : callback(null, out);
10256
- };
10257
-
10258
- if (!highlight || highlight.length < 3) {
10259
- return done();
10260
- }
10261
-
10262
- delete opt.highlight;
10263
- if (!tokens.length) return done();
10264
- var pending = 0;
10265
- marked.walkTokens(tokens, function (token) {
10266
- if (token.type === 'code') {
10267
- pending++;
10268
- setTimeout(function () {
10269
- highlight(token.text, token.lang, function (err, code) {
10270
- if (err) {
10271
- return done(err);
10272
- }
10273
-
10274
- if (code != null && code !== token.text) {
10275
- token.text = code;
10276
- token.escaped = true;
10348
+ var done = function done(err) {
10349
+ var out;
10350
+ if (!err) {
10351
+ try {
10352
+ if (opt.walkTokens) {
10353
+ marked.walkTokens(tokens, opt.walkTokens);
10277
10354
  }
10278
-
10279
- pending--;
10280
-
10281
- if (pending === 0) {
10282
- done();
10355
+ out = parser(tokens, opt);
10356
+ if (opt.hooks) {
10357
+ out = opt.hooks.postprocess(out);
10283
10358
  }
10284
- });
10285
- }, 0);
10359
+ } catch (e) {
10360
+ err = e;
10361
+ }
10362
+ }
10363
+ opt.highlight = highlight;
10364
+ return err ? throwError(err) : callback(null, out);
10365
+ };
10366
+ if (!highlight || highlight.length < 3) {
10367
+ return done();
10368
+ }
10369
+ delete opt.highlight;
10370
+ if (!tokens.length) return done();
10371
+ var pending = 0;
10372
+ marked.walkTokens(tokens, function (token) {
10373
+ if (token.type === 'code') {
10374
+ pending++;
10375
+ setTimeout(function () {
10376
+ highlight(token.text, token.lang, function (err, code) {
10377
+ if (err) {
10378
+ return done(err);
10379
+ }
10380
+ if (code != null && code !== token.text) {
10381
+ token.text = code;
10382
+ token.escaped = true;
10383
+ }
10384
+ pending--;
10385
+ if (pending === 0) {
10386
+ done();
10387
+ }
10388
+ });
10389
+ }, 0);
10390
+ }
10391
+ });
10392
+ if (pending === 0) {
10393
+ done();
10286
10394
  }
10287
- });
10288
-
10289
- if (pending === 0) {
10290
- done();
10395
+ return;
10291
10396
  }
10292
-
10293
- return;
10294
- }
10295
-
10296
- try {
10297
- var _tokens = Lexer_1.lex(src, opt);
10298
-
10299
- if (opt.walkTokens) {
10300
- marked.walkTokens(_tokens, opt.walkTokens);
10397
+ if (opt.async) {
10398
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(function (src) {
10399
+ return lexer(src, opt);
10400
+ }).then(function (tokens) {
10401
+ return opt.walkTokens ? Promise.all(marked.walkTokens(tokens, opt.walkTokens)).then(function () {
10402
+ return tokens;
10403
+ }) : tokens;
10404
+ }).then(function (tokens) {
10405
+ return parser(tokens, opt);
10406
+ }).then(function (html) {
10407
+ return opt.hooks ? opt.hooks.postprocess(html) : html;
10408
+ })["catch"](throwError);
10301
10409
  }
10302
-
10303
- return Parser_1.parse(_tokens, opt);
10304
- } catch (e) {
10305
- e.message += '\nPlease report this to https://github.com/markedjs/marked.';
10306
-
10307
- if (opt.silent) {
10308
- return '<p>An error occurred:</p><pre>' + escape$2(e.message + '', true) + '</pre>';
10410
+ try {
10411
+ if (opt.hooks) {
10412
+ src = opt.hooks.preprocess(src);
10413
+ }
10414
+ var _tokens = lexer(src, opt);
10415
+ if (opt.walkTokens) {
10416
+ marked.walkTokens(_tokens, opt.walkTokens);
10417
+ }
10418
+ var html = parser(_tokens, opt);
10419
+ if (opt.hooks) {
10420
+ html = opt.hooks.postprocess(html);
10421
+ }
10422
+ return html;
10423
+ } catch (e) {
10424
+ return throwError(e);
10309
10425
  }
10426
+ };
10427
+ }
10310
10428
 
10311
- throw e;
10312
- }
10429
+ /**
10430
+ * Marked
10431
+ */
10432
+ function marked(src, opt, callback) {
10433
+ return parseMarkdown(Lexer.lex, Parser.parse)(src, opt, callback);
10313
10434
  }
10435
+
10314
10436
  /**
10315
10437
  * Options
10316
10438
  */
10317
10439
 
10318
-
10319
10440
  marked.options = marked.setOptions = function (opt) {
10320
- merge$2(marked.defaults, opt);
10441
+ marked.defaults = _extends({}, marked.defaults, opt);
10321
10442
  changeDefaults(marked.defaults);
10322
10443
  return marked;
10323
10444
  };
10324
-
10325
10445
  marked.getDefaults = getDefaults;
10326
- marked.defaults = defaults$5;
10446
+ marked.defaults = exports.defaults;
10447
+
10327
10448
  /**
10328
10449
  * Use Extension
10329
10450
  */
10330
10451
 
10331
- marked.use = function (extension) {
10332
- var opts = merge$2({}, extension);
10333
-
10334
- if (extension.renderer) {
10335
- (function () {
10336
- var renderer = marked.defaults.renderer || new Renderer_1();
10452
+ marked.use = function () {
10453
+ var extensions = marked.defaults.extensions || {
10454
+ renderers: {},
10455
+ childTokens: {}
10456
+ };
10457
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10458
+ args[_key] = arguments[_key];
10459
+ }
10460
+ args.forEach(function (pack) {
10461
+ // copy options to new object
10462
+ var opts = _extends({}, pack);
10337
10463
 
10338
- var _loop = function _loop(prop) {
10339
- var prevRenderer = renderer[prop];
10464
+ // set async to true if it was set to true before
10465
+ opts.async = marked.defaults.async || opts.async || false;
10340
10466
 
10341
- renderer[prop] = function () {
10342
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10343
- args[_key] = arguments[_key];
10467
+ // ==-- Parse "addon" extensions --== //
10468
+ if (pack.extensions) {
10469
+ pack.extensions.forEach(function (ext) {
10470
+ if (!ext.name) {
10471
+ throw new Error('extension name required');
10472
+ }
10473
+ if (ext.renderer) {
10474
+ // Renderer extensions
10475
+ var prevRenderer = extensions.renderers[ext.name];
10476
+ if (prevRenderer) {
10477
+ // Replace extension with func to run new extension but fall back if false
10478
+ extensions.renderers[ext.name] = function () {
10479
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
10480
+ args[_key2] = arguments[_key2];
10481
+ }
10482
+ var ret = ext.renderer.apply(this, args);
10483
+ if (ret === false) {
10484
+ ret = prevRenderer.apply(this, args);
10485
+ }
10486
+ return ret;
10487
+ };
10488
+ } else {
10489
+ extensions.renderers[ext.name] = ext.renderer;
10344
10490
  }
10345
-
10346
- var ret = extension.renderer[prop].apply(renderer, args);
10347
-
10348
- if (ret === false) {
10349
- ret = prevRenderer.apply(renderer, args);
10491
+ }
10492
+ if (ext.tokenizer) {
10493
+ // Tokenizer Extensions
10494
+ if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
10495
+ throw new Error("extension level must be 'block' or 'inline'");
10350
10496
  }
10351
-
10352
- return ret;
10353
- };
10354
- };
10355
-
10356
- for (var prop in extension.renderer) {
10357
- _loop(prop);
10358
- }
10359
-
10360
- opts.renderer = renderer;
10361
- })();
10362
- }
10363
-
10364
- if (extension.tokenizer) {
10365
- (function () {
10366
- var tokenizer = marked.defaults.tokenizer || new Tokenizer_1();
10367
-
10368
- var _loop2 = function _loop2(prop) {
10369
- var prevTokenizer = tokenizer[prop];
10370
-
10371
- tokenizer[prop] = function () {
10372
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
10373
- args[_key2] = arguments[_key2];
10497
+ if (extensions[ext.level]) {
10498
+ extensions[ext.level].unshift(ext.tokenizer);
10499
+ } else {
10500
+ extensions[ext.level] = [ext.tokenizer];
10374
10501
  }
10375
-
10376
- var ret = extension.tokenizer[prop].apply(tokenizer, args);
10377
-
10378
- if (ret === false) {
10379
- ret = prevTokenizer.apply(tokenizer, args);
10502
+ if (ext.start) {
10503
+ // Function to check for start of token
10504
+ if (ext.level === 'block') {
10505
+ if (extensions.startBlock) {
10506
+ extensions.startBlock.push(ext.start);
10507
+ } else {
10508
+ extensions.startBlock = [ext.start];
10509
+ }
10510
+ } else if (ext.level === 'inline') {
10511
+ if (extensions.startInline) {
10512
+ extensions.startInline.push(ext.start);
10513
+ } else {
10514
+ extensions.startInline = [ext.start];
10515
+ }
10516
+ }
10380
10517
  }
10518
+ }
10519
+ if (ext.childTokens) {
10520
+ // Child tokens to be visited by walkTokens
10521
+ extensions.childTokens[ext.name] = ext.childTokens;
10522
+ }
10523
+ });
10524
+ opts.extensions = extensions;
10525
+ }
10381
10526
 
10382
- return ret;
10527
+ // ==-- Parse "overwrite" extensions --== //
10528
+ if (pack.renderer) {
10529
+ (function () {
10530
+ var renderer = marked.defaults.renderer || new Renderer();
10531
+ var _loop = function _loop(prop) {
10532
+ var prevRenderer = renderer[prop];
10533
+ // Replace renderer with func to run extension, but fall back if false
10534
+ renderer[prop] = function () {
10535
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
10536
+ args[_key3] = arguments[_key3];
10537
+ }
10538
+ var ret = pack.renderer[prop].apply(renderer, args);
10539
+ if (ret === false) {
10540
+ ret = prevRenderer.apply(renderer, args);
10541
+ }
10542
+ return ret;
10543
+ };
10383
10544
  };
10384
- };
10385
-
10386
- for (var prop in extension.tokenizer) {
10387
- _loop2(prop);
10388
- }
10389
-
10390
- opts.tokenizer = tokenizer;
10391
- })();
10392
- }
10393
-
10394
- if (extension.walkTokens) {
10395
- var walkTokens = marked.defaults.walkTokens;
10396
-
10397
- opts.walkTokens = function (token) {
10398
- extension.walkTokens(token);
10545
+ for (var prop in pack.renderer) {
10546
+ _loop(prop);
10547
+ }
10548
+ opts.renderer = renderer;
10549
+ })();
10550
+ }
10551
+ if (pack.tokenizer) {
10552
+ (function () {
10553
+ var tokenizer = marked.defaults.tokenizer || new Tokenizer();
10554
+ var _loop2 = function _loop2(prop) {
10555
+ var prevTokenizer = tokenizer[prop];
10556
+ // Replace tokenizer with func to run extension, but fall back if false
10557
+ tokenizer[prop] = function () {
10558
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
10559
+ args[_key4] = arguments[_key4];
10560
+ }
10561
+ var ret = pack.tokenizer[prop].apply(tokenizer, args);
10562
+ if (ret === false) {
10563
+ ret = prevTokenizer.apply(tokenizer, args);
10564
+ }
10565
+ return ret;
10566
+ };
10567
+ };
10568
+ for (var prop in pack.tokenizer) {
10569
+ _loop2(prop);
10570
+ }
10571
+ opts.tokenizer = tokenizer;
10572
+ })();
10573
+ }
10399
10574
 
10400
- if (walkTokens) {
10401
- walkTokens(token);
10402
- }
10403
- };
10404
- }
10575
+ // ==-- Parse Hooks extensions --== //
10576
+ if (pack.hooks) {
10577
+ (function () {
10578
+ var hooks = marked.defaults.hooks || new Hooks();
10579
+ var _loop3 = function _loop3(prop) {
10580
+ var prevHook = hooks[prop];
10581
+ if (Hooks.passThroughHooks.has(prop)) {
10582
+ hooks[prop] = function (arg) {
10583
+ if (marked.defaults.async) {
10584
+ return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then(function (ret) {
10585
+ return prevHook.call(hooks, ret);
10586
+ });
10587
+ }
10588
+ var ret = pack.hooks[prop].call(hooks, arg);
10589
+ return prevHook.call(hooks, ret);
10590
+ };
10591
+ } else {
10592
+ hooks[prop] = function () {
10593
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
10594
+ args[_key5] = arguments[_key5];
10595
+ }
10596
+ var ret = pack.hooks[prop].apply(hooks, args);
10597
+ if (ret === false) {
10598
+ ret = prevHook.apply(hooks, args);
10599
+ }
10600
+ return ret;
10601
+ };
10602
+ }
10603
+ };
10604
+ for (var prop in pack.hooks) {
10605
+ _loop3(prop);
10606
+ }
10607
+ opts.hooks = hooks;
10608
+ })();
10609
+ }
10405
10610
 
10406
- marked.setOptions(opts);
10611
+ // ==-- Parse WalkTokens extensions --== //
10612
+ if (pack.walkTokens) {
10613
+ var _walkTokens = marked.defaults.walkTokens;
10614
+ opts.walkTokens = function (token) {
10615
+ var values = [];
10616
+ values.push(pack.walkTokens.call(this, token));
10617
+ if (_walkTokens) {
10618
+ values = values.concat(_walkTokens.call(this, token));
10619
+ }
10620
+ return values;
10621
+ };
10622
+ }
10623
+ marked.setOptions(opts);
10624
+ });
10407
10625
  };
10626
+
10408
10627
  /**
10409
10628
  * Run callback for every token
10410
10629
  */
10411
10630
 
10412
-
10413
10631
  marked.walkTokens = function (tokens, callback) {
10414
- for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
10632
+ var values = [];
10633
+ var _loop4 = function _loop4() {
10415
10634
  var token = _step.value;
10416
- callback(token);
10417
-
10635
+ values = values.concat(callback.call(marked, token));
10418
10636
  switch (token.type) {
10419
10637
  case 'table':
10420
10638
  {
10421
- for (var _iterator2 = _createForOfIteratorHelperLoose(token.tokens.header), _step2; !(_step2 = _iterator2()).done;) {
10639
+ for (var _iterator2 = _createForOfIteratorHelperLoose(token.header), _step2; !(_step2 = _iterator2()).done;) {
10422
10640
  var cell = _step2.value;
10423
- marked.walkTokens(cell, callback);
10641
+ values = values.concat(marked.walkTokens(cell.tokens, callback));
10424
10642
  }
10425
-
10426
- for (var _iterator3 = _createForOfIteratorHelperLoose(token.tokens.cells), _step3; !(_step3 = _iterator3()).done;) {
10643
+ for (var _iterator3 = _createForOfIteratorHelperLoose(token.rows), _step3; !(_step3 = _iterator3()).done;) {
10427
10644
  var row = _step3.value;
10428
-
10429
10645
  for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done;) {
10430
10646
  var _cell = _step4.value;
10431
- marked.walkTokens(_cell, callback);
10647
+ values = values.concat(marked.walkTokens(_cell.tokens, callback));
10432
10648
  }
10433
10649
  }
10434
-
10435
10650
  break;
10436
10651
  }
10437
-
10438
10652
  case 'list':
10439
10653
  {
10440
- marked.walkTokens(token.items, callback);
10654
+ values = values.concat(marked.walkTokens(token.items, callback));
10441
10655
  break;
10442
10656
  }
10443
-
10444
10657
  default:
10445
10658
  {
10446
- if (token.tokens) {
10447
- marked.walkTokens(token.tokens, callback);
10659
+ if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) {
10660
+ // Walk any extensions
10661
+ marked.defaults.extensions.childTokens[token.type].forEach(function (childTokens) {
10662
+ values = values.concat(marked.walkTokens(token[childTokens], callback));
10663
+ });
10664
+ } else if (token.tokens) {
10665
+ values = values.concat(marked.walkTokens(token.tokens, callback));
10448
10666
  }
10449
10667
  }
10450
10668
  }
10669
+ };
10670
+ for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
10671
+ _loop4();
10451
10672
  }
10673
+ return values;
10452
10674
  };
10675
+
10453
10676
  /**
10454
- * Expose
10677
+ * Parse Inline
10678
+ * @param {string} src
10455
10679
  */
10680
+ marked.parseInline = parseMarkdown(Lexer.lexInline, Parser.parseInline);
10456
10681
 
10457
-
10458
- marked.Parser = Parser_1;
10459
- marked.parser = Parser_1.parse;
10460
- marked.Renderer = Renderer_1;
10461
- marked.TextRenderer = TextRenderer_1;
10462
- marked.Lexer = Lexer_1;
10463
- marked.lexer = Lexer_1.lex;
10464
- marked.Tokenizer = Tokenizer_1;
10465
- marked.Slugger = Slugger_1;
10682
+ /**
10683
+ * Expose
10684
+ */
10685
+ marked.Parser = Parser;
10686
+ marked.parser = Parser.parse;
10687
+ marked.Renderer = Renderer;
10688
+ marked.TextRenderer = TextRenderer;
10689
+ marked.Lexer = Lexer;
10690
+ marked.lexer = Lexer.lex;
10691
+ marked.Tokenizer = Tokenizer;
10692
+ marked.Slugger = Slugger;
10693
+ marked.Hooks = Hooks;
10466
10694
  marked.parse = marked;
10467
- var marked_1 = marked;
10468
-
10469
- return marked_1;
10470
-
10471
- })));
10695
+ var options = marked.options;
10696
+ var setOptions = marked.setOptions;
10697
+ var use = marked.use;
10698
+ var walkTokens = marked.walkTokens;
10699
+ var parseInline = marked.parseInline;
10700
+ var parse = marked;
10701
+ var parser = Parser.parse;
10702
+ var lexer = Lexer.lex;
10703
+
10704
+ exports.Hooks = Hooks;
10705
+ exports.Lexer = Lexer;
10706
+ exports.Parser = Parser;
10707
+ exports.Renderer = Renderer;
10708
+ exports.Slugger = Slugger;
10709
+ exports.TextRenderer = TextRenderer;
10710
+ exports.Tokenizer = Tokenizer;
10711
+ exports.getDefaults = getDefaults;
10712
+ exports.lexer = lexer;
10713
+ exports.marked = marked;
10714
+ exports.options = options;
10715
+ exports.parse = parse;
10716
+ exports.parseInline = parseInline;
10717
+ exports.parser = parser;
10718
+ exports.setOptions = setOptions;
10719
+ exports.use = use;
10720
+ exports.walkTokens = walkTokens;
10721
+
10722
+ }));
10472
10723
  });
10473
10724
 
10474
10725
  const textComponentCss = "sqh-text-component{display:block}sqh-text-component p{margin:0}";
@@ -10478,7 +10729,6 @@ const TextComponent = class {
10478
10729
  registerInstance(this, hostRef);
10479
10730
  }
10480
10731
  render() {
10481
- const regex = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i;
10482
10732
  const textStyle = css `
10483
10733
  font-family: ${this.fontfamily || "inherit"};
10484
10734
  font-size: ${this.fontsize ? this.fontsize + "px" : "inherit"};
@@ -10493,14 +10743,14 @@ const TextComponent = class {
10493
10743
  `;
10494
10744
  const divStyle = css `
10495
10745
  background: ${this.background
10496
- ? this.background.match(regex)
10746
+ ? isUrl(this.background)
10497
10747
  ? `url(${this.background}) no-repeat center center;`
10498
10748
  : this.background
10499
10749
  : "inherit"};
10500
10750
  height: ${this.height || "inherit"};
10501
10751
  background-size: contain;
10502
10752
  `;
10503
- const content = this.ismarkdown ? (h("div", { innerHTML: marked(this.text) })) : (this.text);
10753
+ const content = this.ismarkdown ? (h("div", { innerHTML: marked_umd.marked.parse(this.text) })) : (this.text);
10504
10754
  return (!this.ishidden && (h("div", { class: divStyle }, h("p", { class: textStyle }, content))));
10505
10755
  }
10506
10756
  get textEl() { return getElement(this); }