@readme/markdown 6.43.1 → 6.43.2

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.
@@ -2,6 +2,7 @@
2
2
  */
3
3
  const React = require('react');
4
4
  const PropTypes = require('prop-types');
5
+ const escape = require('lodash.escape');
5
6
 
6
7
  const MATCH_SCRIPT_TAGS = /<script\b[^>]*>([\s\S]*?)<\/script *>\n?/gim;
7
8
 
@@ -15,13 +16,6 @@ const extractScripts = (html = '') => {
15
16
  return [cleaned, () => scripts.map(js => window.eval(js))];
16
17
  };
17
18
 
18
- /**
19
- * @hack: https://stackoverflow.com/a/30930653/659661
20
- */
21
- const escapeHTML = html => {
22
- return document.createElement('div').appendChild(document.createTextNode(html)).parentNode.innerHTML;
23
- };
24
-
25
19
  class HTMLBlock extends React.Component {
26
20
  constructor(props) {
27
21
  super(props);
@@ -39,7 +33,7 @@ class HTMLBlock extends React.Component {
39
33
  if (safeMode) {
40
34
  return (
41
35
  <pre className="html-unsafe">
42
- <code>{escapeHTML(html)}</code>
36
+ <code>{escape(html)}</code>
43
37
  </pre>
44
38
  );
45
39
  }
package/dist/main.js CHANGED
@@ -9713,6 +9713,8 @@ var React = __webpack_require__(4466);
9713
9713
 
9714
9714
  var PropTypes = __webpack_require__(5697);
9715
9715
 
9716
+ var escape = __webpack_require__(8686);
9717
+
9716
9718
  var MATCH_SCRIPT_TAGS = /<script\b[^>]*>([\s\S]*?)<\/script *>\n?/gim;
9717
9719
 
9718
9720
  var extractScripts = function extractScripts() {
@@ -9731,14 +9733,6 @@ var extractScripts = function extractScripts() {
9731
9733
  });
9732
9734
  }];
9733
9735
  };
9734
- /**
9735
- * @hack: https://stackoverflow.com/a/30930653/659661
9736
- */
9737
-
9738
-
9739
- var escapeHTML = function escapeHTML(html) {
9740
- return document.createElement('div').appendChild(document.createTextNode(html)).parentNode.innerHTML;
9741
- };
9742
9736
 
9743
9737
  var HTMLBlock = /*#__PURE__*/function (_React$Component) {
9744
9738
  "use strict";
@@ -9779,7 +9773,7 @@ var HTMLBlock = /*#__PURE__*/function (_React$Component) {
9779
9773
  if (safeMode) {
9780
9774
  return /*#__PURE__*/React.createElement("pre", {
9781
9775
  className: "html-unsafe"
9782
- }, /*#__PURE__*/React.createElement("code", null, escapeHTML(html)));
9776
+ }, /*#__PURE__*/React.createElement("code", null, escape(html)));
9783
9777
  }
9784
9778
 
9785
9779
  return /*#__PURE__*/React.createElement("div", {
@@ -33636,6 +33630,227 @@ function wordCharacter(character) {
33636
33630
  }
33637
33631
 
33638
33632
 
33633
+ /***/ }),
33634
+
33635
+ /***/ 8686:
33636
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
33637
+
33638
+ /**
33639
+ * lodash (Custom Build) <https://lodash.com/>
33640
+ * Build: `lodash modularize exports="npm" -o ./`
33641
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
33642
+ * Released under MIT license <https://lodash.com/license>
33643
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
33644
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
33645
+ */
33646
+
33647
+ /** Used as references for various `Number` constants. */
33648
+ var INFINITY = 1 / 0;
33649
+
33650
+ /** `Object#toString` result references. */
33651
+ var symbolTag = '[object Symbol]';
33652
+
33653
+ /** Used to match HTML entities and HTML characters. */
33654
+ var reUnescapedHtml = /[&<>"'`]/g,
33655
+ reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
33656
+
33657
+ /** Used to map characters to HTML entities. */
33658
+ var htmlEscapes = {
33659
+ '&': '&amp;',
33660
+ '<': '&lt;',
33661
+ '>': '&gt;',
33662
+ '"': '&quot;',
33663
+ "'": '&#39;',
33664
+ '`': '&#96;'
33665
+ };
33666
+
33667
+ /** Detect free variable `global` from Node.js. */
33668
+ var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
33669
+
33670
+ /** Detect free variable `self`. */
33671
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
33672
+
33673
+ /** Used as a reference to the global object. */
33674
+ var root = freeGlobal || freeSelf || Function('return this')();
33675
+
33676
+ /**
33677
+ * The base implementation of `_.propertyOf` without support for deep paths.
33678
+ *
33679
+ * @private
33680
+ * @param {Object} object The object to query.
33681
+ * @returns {Function} Returns the new accessor function.
33682
+ */
33683
+ function basePropertyOf(object) {
33684
+ return function(key) {
33685
+ return object == null ? undefined : object[key];
33686
+ };
33687
+ }
33688
+
33689
+ /**
33690
+ * Used by `_.escape` to convert characters to HTML entities.
33691
+ *
33692
+ * @private
33693
+ * @param {string} chr The matched character to escape.
33694
+ * @returns {string} Returns the escaped character.
33695
+ */
33696
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
33697
+
33698
+ /** Used for built-in method references. */
33699
+ var objectProto = Object.prototype;
33700
+
33701
+ /**
33702
+ * Used to resolve the
33703
+ * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
33704
+ * of values.
33705
+ */
33706
+ var objectToString = objectProto.toString;
33707
+
33708
+ /** Built-in value references. */
33709
+ var Symbol = root.Symbol;
33710
+
33711
+ /** Used to convert symbols to primitives and strings. */
33712
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
33713
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
33714
+
33715
+ /**
33716
+ * The base implementation of `_.toString` which doesn't convert nullish
33717
+ * values to empty strings.
33718
+ *
33719
+ * @private
33720
+ * @param {*} value The value to process.
33721
+ * @returns {string} Returns the string.
33722
+ */
33723
+ function baseToString(value) {
33724
+ // Exit early for strings to avoid a performance hit in some environments.
33725
+ if (typeof value == 'string') {
33726
+ return value;
33727
+ }
33728
+ if (isSymbol(value)) {
33729
+ return symbolToString ? symbolToString.call(value) : '';
33730
+ }
33731
+ var result = (value + '');
33732
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
33733
+ }
33734
+
33735
+ /**
33736
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
33737
+ * and has a `typeof` result of "object".
33738
+ *
33739
+ * @static
33740
+ * @memberOf _
33741
+ * @since 4.0.0
33742
+ * @category Lang
33743
+ * @param {*} value The value to check.
33744
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
33745
+ * @example
33746
+ *
33747
+ * _.isObjectLike({});
33748
+ * // => true
33749
+ *
33750
+ * _.isObjectLike([1, 2, 3]);
33751
+ * // => true
33752
+ *
33753
+ * _.isObjectLike(_.noop);
33754
+ * // => false
33755
+ *
33756
+ * _.isObjectLike(null);
33757
+ * // => false
33758
+ */
33759
+ function isObjectLike(value) {
33760
+ return !!value && typeof value == 'object';
33761
+ }
33762
+
33763
+ /**
33764
+ * Checks if `value` is classified as a `Symbol` primitive or object.
33765
+ *
33766
+ * @static
33767
+ * @memberOf _
33768
+ * @since 4.0.0
33769
+ * @category Lang
33770
+ * @param {*} value The value to check.
33771
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
33772
+ * @example
33773
+ *
33774
+ * _.isSymbol(Symbol.iterator);
33775
+ * // => true
33776
+ *
33777
+ * _.isSymbol('abc');
33778
+ * // => false
33779
+ */
33780
+ function isSymbol(value) {
33781
+ return typeof value == 'symbol' ||
33782
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
33783
+ }
33784
+
33785
+ /**
33786
+ * Converts `value` to a string. An empty string is returned for `null`
33787
+ * and `undefined` values. The sign of `-0` is preserved.
33788
+ *
33789
+ * @static
33790
+ * @memberOf _
33791
+ * @since 4.0.0
33792
+ * @category Lang
33793
+ * @param {*} value The value to process.
33794
+ * @returns {string} Returns the string.
33795
+ * @example
33796
+ *
33797
+ * _.toString(null);
33798
+ * // => ''
33799
+ *
33800
+ * _.toString(-0);
33801
+ * // => '-0'
33802
+ *
33803
+ * _.toString([1, 2, 3]);
33804
+ * // => '1,2,3'
33805
+ */
33806
+ function toString(value) {
33807
+ return value == null ? '' : baseToString(value);
33808
+ }
33809
+
33810
+ /**
33811
+ * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
33812
+ * their corresponding HTML entities.
33813
+ *
33814
+ * **Note:** No other characters are escaped. To escape additional
33815
+ * characters use a third-party library like [_he_](https://mths.be/he).
33816
+ *
33817
+ * Though the ">" character is escaped for symmetry, characters like
33818
+ * ">" and "/" don't need escaping in HTML and have no special meaning
33819
+ * unless they're part of a tag or unquoted attribute value. See
33820
+ * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
33821
+ * (under "semi-related fun fact") for more details.
33822
+ *
33823
+ * Backticks are escaped because in IE < 9, they can break out of
33824
+ * attribute values or HTML comments. See [#59](https://html5sec.org/#59),
33825
+ * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
33826
+ * [#133](https://html5sec.org/#133) of the
33827
+ * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
33828
+ *
33829
+ * When working with HTML you should always
33830
+ * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
33831
+ * XSS vectors.
33832
+ *
33833
+ * @static
33834
+ * @since 0.1.0
33835
+ * @memberOf _
33836
+ * @category String
33837
+ * @param {string} [string=''] The string to escape.
33838
+ * @returns {string} Returns the escaped string.
33839
+ * @example
33840
+ *
33841
+ * _.escape('fred, barney, & pebbles');
33842
+ * // => 'fred, barney, &amp; pebbles'
33843
+ */
33844
+ function escape(string) {
33845
+ string = toString(string);
33846
+ return (string && reHasUnescapedHtml.test(string))
33847
+ ? string.replace(reUnescapedHtml, escapeHtmlChar)
33848
+ : string;
33849
+ }
33850
+
33851
+ module.exports = escape;
33852
+
33853
+
33639
33854
  /***/ }),
33640
33855
 
33641
33856
  /***/ 5683:
package/dist/main.node.js CHANGED
@@ -9713,6 +9713,8 @@ var React = __webpack_require__(4466);
9713
9713
 
9714
9714
  var PropTypes = __webpack_require__(5697);
9715
9715
 
9716
+ var escape = __webpack_require__(8686);
9717
+
9716
9718
  var MATCH_SCRIPT_TAGS = /<script\b[^>]*>([\s\S]*?)<\/script *>\n?/gim;
9717
9719
 
9718
9720
  var extractScripts = function extractScripts() {
@@ -9731,14 +9733,6 @@ var extractScripts = function extractScripts() {
9731
9733
  });
9732
9734
  }];
9733
9735
  };
9734
- /**
9735
- * @hack: https://stackoverflow.com/a/30930653/659661
9736
- */
9737
-
9738
-
9739
- var escapeHTML = function escapeHTML(html) {
9740
- return document.createElement('div').appendChild(document.createTextNode(html)).parentNode.innerHTML;
9741
- };
9742
9736
 
9743
9737
  var HTMLBlock = /*#__PURE__*/function (_React$Component) {
9744
9738
  "use strict";
@@ -9779,7 +9773,7 @@ var HTMLBlock = /*#__PURE__*/function (_React$Component) {
9779
9773
  if (safeMode) {
9780
9774
  return /*#__PURE__*/React.createElement("pre", {
9781
9775
  className: "html-unsafe"
9782
- }, /*#__PURE__*/React.createElement("code", null, escapeHTML(html)));
9776
+ }, /*#__PURE__*/React.createElement("code", null, escape(html)));
9783
9777
  }
9784
9778
 
9785
9779
  return /*#__PURE__*/React.createElement("div", {
@@ -16474,6 +16468,227 @@ function wordCharacter(character) {
16474
16468
  }
16475
16469
 
16476
16470
 
16471
+ /***/ }),
16472
+
16473
+ /***/ 8686:
16474
+ /***/ ((module) => {
16475
+
16476
+ /**
16477
+ * lodash (Custom Build) <https://lodash.com/>
16478
+ * Build: `lodash modularize exports="npm" -o ./`
16479
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
16480
+ * Released under MIT license <https://lodash.com/license>
16481
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
16482
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
16483
+ */
16484
+
16485
+ /** Used as references for various `Number` constants. */
16486
+ var INFINITY = 1 / 0;
16487
+
16488
+ /** `Object#toString` result references. */
16489
+ var symbolTag = '[object Symbol]';
16490
+
16491
+ /** Used to match HTML entities and HTML characters. */
16492
+ var reUnescapedHtml = /[&<>"'`]/g,
16493
+ reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
16494
+
16495
+ /** Used to map characters to HTML entities. */
16496
+ var htmlEscapes = {
16497
+ '&': '&amp;',
16498
+ '<': '&lt;',
16499
+ '>': '&gt;',
16500
+ '"': '&quot;',
16501
+ "'": '&#39;',
16502
+ '`': '&#96;'
16503
+ };
16504
+
16505
+ /** Detect free variable `global` from Node.js. */
16506
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
16507
+
16508
+ /** Detect free variable `self`. */
16509
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
16510
+
16511
+ /** Used as a reference to the global object. */
16512
+ var root = freeGlobal || freeSelf || Function('return this')();
16513
+
16514
+ /**
16515
+ * The base implementation of `_.propertyOf` without support for deep paths.
16516
+ *
16517
+ * @private
16518
+ * @param {Object} object The object to query.
16519
+ * @returns {Function} Returns the new accessor function.
16520
+ */
16521
+ function basePropertyOf(object) {
16522
+ return function(key) {
16523
+ return object == null ? undefined : object[key];
16524
+ };
16525
+ }
16526
+
16527
+ /**
16528
+ * Used by `_.escape` to convert characters to HTML entities.
16529
+ *
16530
+ * @private
16531
+ * @param {string} chr The matched character to escape.
16532
+ * @returns {string} Returns the escaped character.
16533
+ */
16534
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
16535
+
16536
+ /** Used for built-in method references. */
16537
+ var objectProto = Object.prototype;
16538
+
16539
+ /**
16540
+ * Used to resolve the
16541
+ * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
16542
+ * of values.
16543
+ */
16544
+ var objectToString = objectProto.toString;
16545
+
16546
+ /** Built-in value references. */
16547
+ var Symbol = root.Symbol;
16548
+
16549
+ /** Used to convert symbols to primitives and strings. */
16550
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
16551
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
16552
+
16553
+ /**
16554
+ * The base implementation of `_.toString` which doesn't convert nullish
16555
+ * values to empty strings.
16556
+ *
16557
+ * @private
16558
+ * @param {*} value The value to process.
16559
+ * @returns {string} Returns the string.
16560
+ */
16561
+ function baseToString(value) {
16562
+ // Exit early for strings to avoid a performance hit in some environments.
16563
+ if (typeof value == 'string') {
16564
+ return value;
16565
+ }
16566
+ if (isSymbol(value)) {
16567
+ return symbolToString ? symbolToString.call(value) : '';
16568
+ }
16569
+ var result = (value + '');
16570
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
16571
+ }
16572
+
16573
+ /**
16574
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
16575
+ * and has a `typeof` result of "object".
16576
+ *
16577
+ * @static
16578
+ * @memberOf _
16579
+ * @since 4.0.0
16580
+ * @category Lang
16581
+ * @param {*} value The value to check.
16582
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
16583
+ * @example
16584
+ *
16585
+ * _.isObjectLike({});
16586
+ * // => true
16587
+ *
16588
+ * _.isObjectLike([1, 2, 3]);
16589
+ * // => true
16590
+ *
16591
+ * _.isObjectLike(_.noop);
16592
+ * // => false
16593
+ *
16594
+ * _.isObjectLike(null);
16595
+ * // => false
16596
+ */
16597
+ function isObjectLike(value) {
16598
+ return !!value && typeof value == 'object';
16599
+ }
16600
+
16601
+ /**
16602
+ * Checks if `value` is classified as a `Symbol` primitive or object.
16603
+ *
16604
+ * @static
16605
+ * @memberOf _
16606
+ * @since 4.0.0
16607
+ * @category Lang
16608
+ * @param {*} value The value to check.
16609
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
16610
+ * @example
16611
+ *
16612
+ * _.isSymbol(Symbol.iterator);
16613
+ * // => true
16614
+ *
16615
+ * _.isSymbol('abc');
16616
+ * // => false
16617
+ */
16618
+ function isSymbol(value) {
16619
+ return typeof value == 'symbol' ||
16620
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
16621
+ }
16622
+
16623
+ /**
16624
+ * Converts `value` to a string. An empty string is returned for `null`
16625
+ * and `undefined` values. The sign of `-0` is preserved.
16626
+ *
16627
+ * @static
16628
+ * @memberOf _
16629
+ * @since 4.0.0
16630
+ * @category Lang
16631
+ * @param {*} value The value to process.
16632
+ * @returns {string} Returns the string.
16633
+ * @example
16634
+ *
16635
+ * _.toString(null);
16636
+ * // => ''
16637
+ *
16638
+ * _.toString(-0);
16639
+ * // => '-0'
16640
+ *
16641
+ * _.toString([1, 2, 3]);
16642
+ * // => '1,2,3'
16643
+ */
16644
+ function toString(value) {
16645
+ return value == null ? '' : baseToString(value);
16646
+ }
16647
+
16648
+ /**
16649
+ * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
16650
+ * their corresponding HTML entities.
16651
+ *
16652
+ * **Note:** No other characters are escaped. To escape additional
16653
+ * characters use a third-party library like [_he_](https://mths.be/he).
16654
+ *
16655
+ * Though the ">" character is escaped for symmetry, characters like
16656
+ * ">" and "/" don't need escaping in HTML and have no special meaning
16657
+ * unless they're part of a tag or unquoted attribute value. See
16658
+ * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
16659
+ * (under "semi-related fun fact") for more details.
16660
+ *
16661
+ * Backticks are escaped because in IE < 9, they can break out of
16662
+ * attribute values or HTML comments. See [#59](https://html5sec.org/#59),
16663
+ * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
16664
+ * [#133](https://html5sec.org/#133) of the
16665
+ * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
16666
+ *
16667
+ * When working with HTML you should always
16668
+ * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
16669
+ * XSS vectors.
16670
+ *
16671
+ * @static
16672
+ * @since 0.1.0
16673
+ * @memberOf _
16674
+ * @category String
16675
+ * @param {string} [string=''] The string to escape.
16676
+ * @returns {string} Returns the escaped string.
16677
+ * @example
16678
+ *
16679
+ * _.escape('fred, barney, & pebbles');
16680
+ * // => 'fred, barney, &amp; pebbles'
16681
+ */
16682
+ function escape(string) {
16683
+ string = toString(string);
16684
+ return (string && reHasUnescapedHtml.test(string))
16685
+ ? string.replace(reUnescapedHtml, escapeHtmlChar)
16686
+ : string;
16687
+ }
16688
+
16689
+ module.exports = escape;
16690
+
16691
+
16477
16692
  /***/ }),
16478
16693
 
16479
16694
  /***/ 5683:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@readme/markdown",
3
3
  "description": "ReadMe's React-based Markdown parser",
4
4
  "author": "Rafe Goldberg <rafe@readme.io>",
5
- "version": "6.43.1",
5
+ "version": "6.43.2",
6
6
  "main": "dist/main.node.js",
7
7
  "browser": "dist/main.js",
8
8
  "files": [
@@ -32,6 +32,7 @@
32
32
  "copy-to-clipboard": "^3.3.1",
33
33
  "hast-util-sanitize": "^4.0.0",
34
34
  "hast-util-to-string": "^1.0.4",
35
+ "lodash.escape": "^4.0.1",
35
36
  "lodash.kebabcase": "^4.1.1",
36
37
  "mdast-util-toc": "^5.1.0",
37
38
  "path-browserify": "^1.0.1",