@readme/markdown 7.4.3 → 7.5.0

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
@@ -50,6 +50,14 @@ A module ([`RMDXModule`](#rmdxmodule)) of renderable components
50
50
 
51
51
  Compiles an ast to mdx.
52
52
 
53
+ ###### Parameters
54
+
55
+ Extends [`remark-stringify` options](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options).
56
+
57
+ ###### Returns
58
+
59
+ An mdx string.
60
+
53
61
  #### `mdast`
54
62
 
55
63
  Parses mdx to an mdast.
package/dist/lib/mdx.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const mdx: (tree: any, { hast }?: {
1
+ export declare const mdx: (tree: any, { hast, ...opts }?: {
2
2
  hast?: boolean;
3
3
  }) => string;
4
4
  export default mdx;
package/dist/main.js CHANGED
@@ -65339,6 +65339,20 @@ const readmeToMdx = () => tree => {
65339
65339
  });
65340
65340
  }
65341
65341
  });
65342
+ visit(tree, 'html', (node, index, parent) => {
65343
+ const html = node.value;
65344
+ const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
65345
+ if (!isScriptOrStyleTag.includes(true))
65346
+ return;
65347
+ parent.children.splice(index, 1, {
65348
+ type: 'html-block',
65349
+ children: [{ type: 'text', value: html }],
65350
+ data: {
65351
+ hName: 'html-block',
65352
+ hProperties: { html },
65353
+ },
65354
+ });
65355
+ });
65342
65356
  return tree;
65343
65357
  };
65344
65358
  /* harmony default export */ const readme_to_mdx = (readmeToMdx);
@@ -93982,6 +93996,17 @@ function compilers() {
93982
93996
  /* harmony default export */ const processor_compile = (compilers);
93983
93997
 
93984
93998
  ;// CONCATENATED MODULE: ./lib/mdx.ts
93999
+ var mdx_rest = (undefined && undefined.__rest) || function (s, e) {
94000
+ var t = {};
94001
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
94002
+ t[p] = s[p];
94003
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
94004
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
94005
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
94006
+ t[p[i]] = s[p[i]];
94007
+ }
94008
+ return t;
94009
+ };
93985
94010
 
93986
94011
 
93987
94012
 
@@ -93989,7 +94014,8 @@ function compilers() {
93989
94014
 
93990
94015
 
93991
94016
 
93992
- const mdx_mdx = (tree, { hast = false } = {}) => {
94017
+ const mdx_mdx = (tree, _a = {}) => {
94018
+ var { hast = false } = _a, opts = mdx_rest(_a, ["hast"]);
93993
94019
  const processor = unified()
93994
94020
  .use(hast ? rehypeRemark : undefined)
93995
94021
  .use(remarkMdx)
@@ -93998,7 +94024,7 @@ const mdx_mdx = (tree, { hast = false } = {}) => {
93998
94024
  .use(readme_to_mdx)
93999
94025
  .use(tables_to_jsx)
94000
94026
  .use(processor_compile)
94001
- .use(remarkStringify);
94027
+ .use(remarkStringify, opts);
94002
94028
  return processor.stringify(processor.runSync(tree));
94003
94029
  };
94004
94030
  /* harmony default export */ const lib_mdx = (mdx_mdx);
package/dist/main.node.js CHANGED
@@ -66326,6 +66326,20 @@ const readmeToMdx = () => tree => {
66326
66326
  });
66327
66327
  }
66328
66328
  });
66329
+ visit(tree, 'html', (node, index, parent) => {
66330
+ const html = node.value;
66331
+ const isScriptOrStyleTag = [!!html.match(/^<(?:style|script)/i), !!html.match(/<\/(?:style|script)>$/i)];
66332
+ if (!isScriptOrStyleTag.includes(true))
66333
+ return;
66334
+ parent.children.splice(index, 1, {
66335
+ type: 'html-block',
66336
+ children: [{ type: 'text', value: html }],
66337
+ data: {
66338
+ hName: 'html-block',
66339
+ hProperties: { html },
66340
+ },
66341
+ });
66342
+ });
66329
66343
  return tree;
66330
66344
  };
66331
66345
  /* harmony default export */ const readme_to_mdx = (readmeToMdx);
@@ -94969,6 +94983,17 @@ function compilers() {
94969
94983
  /* harmony default export */ const processor_compile = (compilers);
94970
94984
 
94971
94985
  ;// CONCATENATED MODULE: ./lib/mdx.ts
94986
+ var mdx_rest = (undefined && undefined.__rest) || function (s, e) {
94987
+ var t = {};
94988
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
94989
+ t[p] = s[p];
94990
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
94991
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
94992
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
94993
+ t[p[i]] = s[p[i]];
94994
+ }
94995
+ return t;
94996
+ };
94972
94997
 
94973
94998
 
94974
94999
 
@@ -94976,7 +95001,8 @@ function compilers() {
94976
95001
 
94977
95002
 
94978
95003
 
94979
- const mdx_mdx = (tree, { hast = false } = {}) => {
95004
+ const mdx_mdx = (tree, _a = {}) => {
95005
+ var { hast = false } = _a, opts = mdx_rest(_a, ["hast"]);
94980
95006
  const processor = unified()
94981
95007
  .use(hast ? rehypeRemark : undefined)
94982
95008
  .use(remarkMdx)
@@ -94985,7 +95011,7 @@ const mdx_mdx = (tree, { hast = false } = {}) => {
94985
95011
  .use(readme_to_mdx)
94986
95012
  .use(tables_to_jsx)
94987
95013
  .use(processor_compile)
94988
- .use(remarkStringify);
95014
+ .use(remarkStringify, opts);
94989
95015
  return processor.stringify(processor.runSync(tree));
94990
95016
  };
94991
95017
  /* harmony default export */ const lib_mdx = (mdx_mdx);
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": "7.4.3",
5
+ "version": "7.5.0",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",