@readme/markdown 6.74.0 → 6.74.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.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- @readme/markdown
2
- ===
1
+ # @readme/markdown
2
+
3
3
  <img align="right" width="26%" src="https://owlbertsio-resized.s3.amazonaws.com/Reading.psd.full.png">
4
4
 
5
5
  ReadMe's flavored Markdown parser and MDX rendering engine. <img align=center src=https://github.com/readmeio/markdown/workflows/CI/badge.svg alt="RDMD CI Status">
@@ -14,28 +14,24 @@ By default, the updated markdown package exports a function which takes a string
14
14
 
15
15
  ```jsx
16
16
  import React from 'react';
17
- import rdmd from "@readme/markdown";
17
+ import rdmd from '@readme/markdown';
18
18
 
19
- export default ({ body }) => (
20
- <div className="markdown-body">
21
- {rdmd(body)}
22
- </div>
23
- );
19
+ export default ({ body }) => <div className="markdown-body">{rdmd(body)}</div>;
24
20
  ```
25
21
 
26
22
  ### Export Methods
27
23
 
28
24
  In addition to the default React processor, the package exports some other methods for transforming ReadMe-flavored markdown:
29
25
 
30
- | Export | Description | Arguments |
31
- | -------:|:---------------------------------------------- |:--------------- |
32
- |*`react`*|_(default)_ returns a VDOM tree object |`text`, `options`|
33
- |*`md`* | transform mdast in to ReadMe-flavored markdown |`tree`, `options`|
34
- |*`html`* | transform markdown in to HTML |`text`, `options`|
35
- |*`mdast`*| transform markdown to an mdast object |`text`, `options`|
36
- |*`hast`* | transform markdown to HAST object |`text`, `options`|
37
- |*`plain`*| transform markdown to plain text |`text`, `options`|
38
- |*`utils`*| contexts, defaults, helpers, etc. | N/A |
26
+ | Export | Description | Arguments |
27
+ | --------: | :--------------------------------------------- | :---------------- |
28
+ | _`react`_ | _(default)_ returns a VDOM tree object | `text`, `options` |
29
+ | _`md`_ | transform mdast in to ReadMe-flavored markdown | `tree`, `options` |
30
+ | _`html`_ | transform markdown in to HTML | `text`, `options` |
31
+ | _`mdast`_ | transform markdown to an mdast object | `text`, `options` |
32
+ | _`hast`_ | transform markdown to HAST object | `text`, `options` |
33
+ | _`plain`_ | transform markdown to plain text | `text`, `options` |
34
+ | _`utils`_ | contexts, defaults, helpers, etc. | N/A |
39
35
 
40
36
  ### Settings & Options
41
37
 
package/dist/main.js CHANGED
@@ -8517,7 +8517,7 @@ var options = {
8517
8517
  },
8518
8518
  safeMode: false,
8519
8519
  settings: {
8520
- position: false
8520
+ position: true
8521
8521
  },
8522
8522
  theme: 'light'
8523
8523
  };
@@ -10095,44 +10095,28 @@ module.exports = function () {
10095
10095
  /***/ 4625:
10096
10096
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10097
10097
 
10098
- var _defineProperty = __webpack_require__(8416);
10099
- var _slicedToArray = __webpack_require__(7424);
10100
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10101
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10102
- var flatMap = __webpack_require__(5885);
10098
+ var _require = __webpack_require__(6393),
10099
+ SKIP = _require.SKIP,
10100
+ visit = _require.visit;
10103
10101
  var collectValues = function collectValues(_ref) {
10104
10102
  var value = _ref.value,
10105
10103
  children = _ref.children;
10106
10104
  if (value) return value;
10107
- if (children) return children.flatMap(collectValues);
10105
+ if (children) return children.flatMap(collectValues).join(' ');
10108
10106
  return '';
10109
10107
  };
10110
- var valuesToString = function valuesToString(node) {
10111
- var values = collectValues(node);
10112
- return Array.isArray(values) ? values.join(' ') : values;
10113
- };
10114
10108
 
10115
10109
  // Flattens table values and adds them as a seperate, easily-accessible key within children
10116
10110
  function transformer(ast) {
10117
- return flatMap(ast, function (node) {
10118
- if (node.tagName === 'table') {
10119
- var _node$children = _slicedToArray(node.children, 2),
10120
- header = _node$children[0],
10121
- body = _node$children[1];
10122
- // hAST tables are deeply nested with an innumerable amount of children
10123
- // This is necessary to pullout all the relevant strings
10124
- return [_objectSpread(_objectSpread({}, node), {}, {
10125
- children: [_objectSpread(_objectSpread({}, node.children[0]), {}, {
10126
- value: valuesToString(header)
10127
- }), body ? _objectSpread(_objectSpread({}, node.children[1]), {}, {
10128
- value: valuesToString(body)
10129
- }) : null].filter(function (x) {
10130
- return x;
10131
- })
10132
- })];
10133
- }
10134
- return [node];
10111
+ visit(ast, {
10112
+ tagName: 'table'
10113
+ }, function (node) {
10114
+ node.children.forEach(function (child) {
10115
+ child.value = collectValues(child).trimStart().trimEnd().replaceAll(/\s+/g, ' ');
10116
+ });
10117
+ return SKIP;
10135
10118
  });
10119
+ return ast;
10136
10120
  }
10137
10121
  module.exports = function () {
10138
10122
  return transformer;
@@ -10162,7 +10146,7 @@ var unist_util_visit = __webpack_require__(6393);
10162
10146
 
10163
10147
  var singleCodeTabs = function singleCodeTabs() {
10164
10148
  return function (tree) {
10165
- (0,unist_util_visit/* visit */.Vn)(tree, function (node, index, parent) {
10149
+ (0,unist_util_visit.visit)(tree, function (node, index, parent) {
10166
10150
  if (node.type === 'code' && (node.lang || node.meta) && parent.type !== 'code-tabs') {
10167
10151
  Object.assign(node, {
10168
10152
  className: 'tab-panel',
@@ -10206,12 +10190,12 @@ var rxEscapedPipe = /\\\|/g;
10206
10190
  */
10207
10191
  var tableCellInlineCode = function tableCellInlineCode() {
10208
10192
  return function (tree) {
10209
- (0,unist_util_visit/* visit */.Vn)(tree, [{
10193
+ (0,unist_util_visit.visit)(tree, [{
10210
10194
  tagName: 'th'
10211
10195
  }, {
10212
10196
  tagName: 'td'
10213
10197
  }], function (tableCellNode) {
10214
- (0,unist_util_visit/* visit */.Vn)(tableCellNode, {
10198
+ (0,unist_util_visit.visit)(tableCellNode, {
10215
10199
  tagName: 'code'
10216
10200
  }, function (inlineCodeNode) {
10217
10201
  var textNode = inlineCodeNode.children[0];
@@ -10292,7 +10276,7 @@ var reusableContentTransformer = function reusableContentTransformer() {
10292
10276
  return undefined;
10293
10277
  };
10294
10278
  return function (tree) {
10295
- (0,unist_util_visit/* visit */.Vn)(tree, 'html', function (node, index, parent) {
10279
+ (0,unist_util_visit.visit)(tree, 'html', function (node, index, parent) {
10296
10280
  var result = regexp.exec(node.value);
10297
10281
  if (!result || !result.groups.tag) return;
10298
10282
  var tag = result.groups.tag;
@@ -34003,8 +33987,12 @@ function selectAll(selector, node) {
34003
33987
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
34004
33988
 
34005
33989
  "use strict";
33990
+ __webpack_require__.r(__webpack_exports__);
34006
33991
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
34007
- /* harmony export */ "Vn": () => (/* binding */ visit)
33992
+ /* harmony export */ "CONTINUE": () => (/* reexport safe */ unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__.dR),
33993
+ /* harmony export */ "EXIT": () => (/* reexport safe */ unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__.BK),
33994
+ /* harmony export */ "SKIP": () => (/* reexport safe */ unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__.AM),
33995
+ /* harmony export */ "visit": () => (/* binding */ visit)
34008
33996
  /* harmony export */ });
34009
33997
  /* harmony import */ var unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5605);
34010
33998
  /**
@@ -34079,12 +34067,12 @@ const visit =
34079
34067
 
34080
34068
  // EXPORTS
34081
34069
  __webpack_require__.d(__webpack_exports__, {
34070
+ "dR": () => (/* binding */ CONTINUE),
34071
+ "BK": () => (/* binding */ EXIT),
34082
34072
  "AM": () => (/* binding */ SKIP),
34083
34073
  "S4": () => (/* binding */ visitParents)
34084
34074
  });
34085
34075
 
34086
- // UNUSED EXPORTS: CONTINUE, EXIT
34087
-
34088
34076
  ;// CONCATENATED MODULE: ./node_modules/unist-util-visit/node_modules/unist-util-is/index.js
34089
34077
  /**
34090
34078
  * @typedef {import('unist').Node} Node
@@ -34995,7 +34983,7 @@ function hast(text) {
34995
34983
  opts = _setup18[1];
34996
34984
  var rdmd = htmlProcessor(opts).use(tableFlattening);
34997
34985
  var node = rdmd.parse(text);
34998
- return rdmd.runSync(node);
34986
+ return rdmd.runSync(node, text);
34999
34987
  }
35000
34988
 
35001
34989
  /**
package/dist/main.node.js CHANGED
@@ -8886,7 +8886,7 @@ var options = {
8886
8886
  },
8887
8887
  safeMode: false,
8888
8888
  settings: {
8889
- position: false
8889
+ position: true
8890
8890
  },
8891
8891
  theme: 'light'
8892
8892
  };
@@ -10471,44 +10471,28 @@ module.exports = function () {
10471
10471
  /***/ 4625:
10472
10472
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10473
10473
 
10474
- var _defineProperty = __webpack_require__(8416);
10475
- var _slicedToArray = __webpack_require__(7424);
10476
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10477
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10478
- var flatMap = __webpack_require__(5885);
10474
+ var _require = __webpack_require__(6393),
10475
+ SKIP = _require.SKIP,
10476
+ visit = _require.visit;
10479
10477
  var collectValues = function collectValues(_ref) {
10480
10478
  var value = _ref.value,
10481
10479
  children = _ref.children;
10482
10480
  if (value) return value;
10483
- if (children) return children.flatMap(collectValues);
10481
+ if (children) return children.flatMap(collectValues).join(' ');
10484
10482
  return '';
10485
10483
  };
10486
- var valuesToString = function valuesToString(node) {
10487
- var values = collectValues(node);
10488
- return Array.isArray(values) ? values.join(' ') : values;
10489
- };
10490
10484
 
10491
10485
  // Flattens table values and adds them as a seperate, easily-accessible key within children
10492
10486
  function transformer(ast) {
10493
- return flatMap(ast, function (node) {
10494
- if (node.tagName === 'table') {
10495
- var _node$children = _slicedToArray(node.children, 2),
10496
- header = _node$children[0],
10497
- body = _node$children[1];
10498
- // hAST tables are deeply nested with an innumerable amount of children
10499
- // This is necessary to pullout all the relevant strings
10500
- return [_objectSpread(_objectSpread({}, node), {}, {
10501
- children: [_objectSpread(_objectSpread({}, node.children[0]), {}, {
10502
- value: valuesToString(header)
10503
- }), body ? _objectSpread(_objectSpread({}, node.children[1]), {}, {
10504
- value: valuesToString(body)
10505
- }) : null].filter(function (x) {
10506
- return x;
10507
- })
10508
- })];
10509
- }
10510
- return [node];
10487
+ visit(ast, {
10488
+ tagName: 'table'
10489
+ }, function (node) {
10490
+ node.children.forEach(function (child) {
10491
+ child.value = collectValues(child).trimStart().trimEnd().replaceAll(/\s+/g, ' ');
10492
+ });
10493
+ return SKIP;
10511
10494
  });
10495
+ return ast;
10512
10496
  }
10513
10497
  module.exports = function () {
10514
10498
  return transformer;
@@ -10538,7 +10522,7 @@ var unist_util_visit = __webpack_require__(6393);
10538
10522
 
10539
10523
  var singleCodeTabs = function singleCodeTabs() {
10540
10524
  return function (tree) {
10541
- (0,unist_util_visit/* visit */.Vn)(tree, function (node, index, parent) {
10525
+ (0,unist_util_visit.visit)(tree, function (node, index, parent) {
10542
10526
  if (node.type === 'code' && (node.lang || node.meta) && parent.type !== 'code-tabs') {
10543
10527
  Object.assign(node, {
10544
10528
  className: 'tab-panel',
@@ -10582,12 +10566,12 @@ var rxEscapedPipe = /\\\|/g;
10582
10566
  */
10583
10567
  var tableCellInlineCode = function tableCellInlineCode() {
10584
10568
  return function (tree) {
10585
- (0,unist_util_visit/* visit */.Vn)(tree, [{
10569
+ (0,unist_util_visit.visit)(tree, [{
10586
10570
  tagName: 'th'
10587
10571
  }, {
10588
10572
  tagName: 'td'
10589
10573
  }], function (tableCellNode) {
10590
- (0,unist_util_visit/* visit */.Vn)(tableCellNode, {
10574
+ (0,unist_util_visit.visit)(tableCellNode, {
10591
10575
  tagName: 'code'
10592
10576
  }, function (inlineCodeNode) {
10593
10577
  var textNode = inlineCodeNode.children[0];
@@ -10641,7 +10625,7 @@ var reusableContentTransformer = function reusableContentTransformer() {
10641
10625
  return undefined;
10642
10626
  };
10643
10627
  return function (tree) {
10644
- (0,unist_util_visit__WEBPACK_IMPORTED_MODULE_3__/* .visit */ .Vn)(tree, 'html', function (node, index, parent) {
10628
+ (0,unist_util_visit__WEBPACK_IMPORTED_MODULE_3__.visit)(tree, 'html', function (node, index, parent) {
10645
10629
  var result = regexp.exec(node.value);
10646
10630
  if (!result || !result.groups.tag) return;
10647
10631
  var tag = result.groups.tag;
@@ -33745,8 +33729,12 @@ function selectAll(selector, node) {
33745
33729
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
33746
33730
 
33747
33731
  "use strict";
33732
+ __webpack_require__.r(__webpack_exports__);
33748
33733
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33749
- /* harmony export */ "Vn": () => (/* binding */ visit)
33734
+ /* harmony export */ "CONTINUE": () => (/* reexport safe */ unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__.dR),
33735
+ /* harmony export */ "EXIT": () => (/* reexport safe */ unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__.BK),
33736
+ /* harmony export */ "SKIP": () => (/* reexport safe */ unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__.AM),
33737
+ /* harmony export */ "visit": () => (/* binding */ visit)
33750
33738
  /* harmony export */ });
33751
33739
  /* harmony import */ var unist_util_visit_parents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9445);
33752
33740
  /**
@@ -33821,12 +33809,12 @@ const visit =
33821
33809
 
33822
33810
  // EXPORTS
33823
33811
  __webpack_require__.d(__webpack_exports__, {
33812
+ "dR": () => (/* binding */ CONTINUE),
33813
+ "BK": () => (/* binding */ EXIT),
33824
33814
  "AM": () => (/* binding */ SKIP),
33825
33815
  "S4": () => (/* binding */ visitParents)
33826
33816
  });
33827
33817
 
33828
- // UNUSED EXPORTS: CONTINUE, EXIT
33829
-
33830
33818
  ;// CONCATENATED MODULE: ./node_modules/unist-util-visit/node_modules/unist-util-is/index.js
33831
33819
  /**
33832
33820
  * @typedef {import('unist').Node} Node
@@ -34736,7 +34724,7 @@ function hast(text) {
34736
34724
  opts = _setup18[1];
34737
34725
  var rdmd = htmlProcessor(opts).use(tableFlattening);
34738
34726
  var node = rdmd.parse(text);
34739
- return rdmd.runSync(node);
34727
+ return rdmd.runSync(node, text);
34740
34728
  }
34741
34729
 
34742
34730
  /**
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.74.0",
5
+ "version": "6.74.2",
6
6
  "main": "dist/main.node.js",
7
7
  "browser": "dist/main.js",
8
8
  "files": [