@readme/markdown 6.75.0-beta.47 → 6.75.0-beta.49

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.
@@ -1,5 +1,6 @@
1
1
  import readmeComponentsTransformer from './readme-components';
2
+ import rehypeToc from './rehype-toc';
2
3
  import readmeToMdx from './readme-to-mdx';
3
- export { readmeComponentsTransformer, readmeToMdx };
4
+ export { readmeComponentsTransformer, rehypeToc, readmeToMdx };
4
5
  declare const _default: (() => (tree: any) => void)[];
5
6
  export default _default;
@@ -0,0 +1,8 @@
1
+ import { Transformer } from 'unified';
2
+ import { Root } from 'hast';
3
+ import { CompiledComponents } from '../../types';
4
+ interface Options {
5
+ components?: CompiledComponents;
6
+ }
7
+ declare const rehypeToc: ({ components }: Options) => Transformer<Root, Root>;
8
+ export default rehypeToc;
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.75.0-beta.47",
5
+ "version": "6.75.0-beta.49",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",
@@ -27,32 +27,35 @@
27
27
  "@mdx-js/mdx": "^3.0.0",
28
28
  "@readme/emojis": "^5.1.0",
29
29
  "@readme/syntax-highlighter": "^13.0.0",
30
+ "@stefanprobst/rehype-extract-toc": "^2.2.0",
30
31
  "copy-to-clipboard": "^3.3.2",
31
32
  "core-js": "^3.36.1",
32
33
  "debug": "^4.3.4",
33
34
  "emoji-regex": "^10.2.1",
34
35
  "gemoji": "^8.1.0",
36
+ "hast-util-from-html": "^2.0.1",
35
37
  "hast-util-sanitize": "^4.0.0",
38
+ "hast-util-to-xast": "^3.0.0",
39
+ "hastscript": "^9.0.0",
36
40
  "lodash.escape": "^4.0.1",
37
41
  "lodash.kebabcase": "^4.1.1",
38
42
  "mdast-util-find-and-replace": "^3.0.1",
39
- "mdast-util-toc": "^5.1.0",
40
43
  "path-browserify": "^1.0.1",
41
44
  "process": "^0.11.10",
42
45
  "prop-types": "^15.8.1",
43
- "rehype-sanitize": "^4.0.0",
46
+ "rehype-remark": "^10.0.0",
47
+ "rehype-slug": "^6.0.0",
44
48
  "remark": "^15.0.1",
45
49
  "remark-frontmatter": "^5.0.0",
46
50
  "remark-gfm": "^4.0.0",
47
51
  "remark-mdx": "^3.0.0",
48
52
  "remark-parse": "^11.0.0",
49
- "remark-rehype": "^11.1.0",
50
- "remark-stringify": "^11.0.0",
51
53
  "trim": "^1.0.1",
52
- "unified": "^8.4.0",
54
+ "unified": "^11.0.4",
53
55
  "unist-util-flatmap": "^1.0.0",
54
56
  "unist-util-visit": "^5.0.0",
55
- "util": "^0.12.5"
57
+ "util": "^0.12.5",
58
+ "xast-util-to-xml": "^4.0.0"
56
59
  },
57
60
  "peerDependencies": {
58
61
  "@mdx-js/react": "^3.0.0",
@@ -77,11 +80,13 @@
77
80
  "@commitlint/config-angular": "^17.4.4",
78
81
  "@commitlint/config-conventional": "^17.4.4",
79
82
  "@readme/eslint-config": "^14.0.0",
83
+ "@readme/markdown-legacy": "npm:@readme/markdown@^6.84.0",
80
84
  "@semantic-release/changelog": "^6.0.3",
81
85
  "@semantic-release/git": "^10.0.1",
82
86
  "@testing-library/jest-dom": "^6.4.2",
83
87
  "@testing-library/react": "^14",
84
88
  "@testing-library/user-event": "^14.5.2",
89
+ "@types/hast": "^3.0.4",
85
90
  "@types/jest": "^29.5.12",
86
91
  "@types/mdast": "^4.0.3",
87
92
  "@types/mdx": "^2.0.12",
@@ -105,6 +110,7 @@
105
110
  "prettier": "^3.2.5",
106
111
  "puppeteer": "^19.8.3",
107
112
  "react-router-dom": "^6.22.3",
113
+ "remark-slug": "^7.0.1",
108
114
  "sass": "^1.77.3",
109
115
  "sass-loader": "^13.2.2",
110
116
  "semantic-release": "^22.0.12",
@@ -1,56 +0,0 @@
1
- const PropTypes = require('prop-types');
2
- const React = require('react');
3
-
4
- function Heading({ tag, showAnchorIcons, ...props }) {
5
- if (!props.children) return '';
6
-
7
- const attrs = {
8
- className: `heading heading-${props.level} header-scroll`,
9
- align: props.align,
10
- };
11
-
12
- const children = [
13
- <div key={`heading-anchor-${props.id}`} className="heading-anchor anchor waypoint" id={props.id} />,
14
- <div key={`heading-text-${props.id}`} className="heading-text">
15
- {props.children}
16
- </div>,
17
- ];
18
-
19
- if (showAnchorIcons) {
20
- const headingText = props.children[1];
21
- children.push(
22
- // eslint-disable-next-line jsx-a11y/anchor-has-content
23
- <a
24
- key={`heading-anchor-icon-${props.id}`}
25
- aria-label={`Skip link to ${headingText}`}
26
- className="heading-anchor-icon fa fa-anchor"
27
- href={`#${props.id}`}
28
- />
29
- );
30
- }
31
-
32
- return React.createElement(tag, attrs, children);
33
- }
34
-
35
- function CreateHeading(level, { showAnchorIcons }) {
36
- // eslint-disable-next-line react/display-name
37
- return props => <Heading {...props} level={level} showAnchorIcons={showAnchorIcons} tag={`h${level}`} />;
38
- }
39
-
40
- Heading.propTypes = {
41
- align: PropTypes.oneOf(['left', 'center', 'right', '']),
42
- children: PropTypes.array.isRequired,
43
- id: PropTypes.string.isRequired,
44
- level: PropTypes.number,
45
- showAnchorIcons: PropTypes.bool,
46
- tag: PropTypes.string.isRequired,
47
- };
48
-
49
- Heading.defaultProps = {
50
- align: '',
51
- id: '',
52
- level: 2,
53
- showAnchorIcons: true,
54
- };
55
-
56
- module.exports = CreateHeading;
@@ -1,31 +0,0 @@
1
- const PropTypes = require('prop-types');
2
- const React = require('react');
3
-
4
- const Style = ({ children, safeMode }) => {
5
- return safeMode ? (
6
- <pre>
7
- <code>{`<style>\n${children}\n</style>`}</code>
8
- </pre>
9
- ) : (
10
- <style>{children}</style>
11
- );
12
- };
13
-
14
- Style.propTypes = {
15
- children: PropTypes.node,
16
- safeMode: PropTypes.bool,
17
- };
18
-
19
- const CreateStyle =
20
- ({ safeMode }) =>
21
- // eslint-disable-next-line react/display-name
22
- props =>
23
- <Style {...props} safeMode={safeMode} />;
24
-
25
- CreateStyle.sanitize = sanitize => {
26
- sanitize.tagNames.push('style');
27
-
28
- return sanitize;
29
- };
30
-
31
- module.exports = CreateStyle;