@readme/markdown 6.75.0-beta.47 → 6.75.0-beta.48
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/components/Heading/index.tsx +31 -0
- package/components/TableOfContents/{index.jsx → index.tsx} +1 -6
- package/components/index.ts +0 -1
- package/dist/components/Heading/index.d.ts +8 -0
- package/dist/components/TableOfContents/index.d.ts +3 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/contexts/index.d.ts +1 -1
- package/dist/index.d.ts +3 -24
- package/dist/lib/ast-processor.d.ts +8 -0
- package/dist/lib/compile.d.ts +9 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/mdx.d.ts +4 -0
- package/dist/lib/run.d.ts +24 -0
- package/dist/main.js +43247 -39581
- package/dist/main.node.js +42754 -39080
- package/dist/processor/transform/index.d.ts +2 -1
- package/dist/processor/transform/rehype-toc.d.ts +8 -0
- package/package.json +8 -6
- package/components/Heading/index.jsx +0 -56
- package/components/Style.jsx +0 -31
|
@@ -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.
|
|
5
|
+
"version": "6.75.0-beta.48",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
@@ -27,29 +27,29 @@
|
|
|
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",
|
|
35
36
|
"hast-util-sanitize": "^4.0.0",
|
|
37
|
+
"hastscript": "^9.0.0",
|
|
36
38
|
"lodash.escape": "^4.0.1",
|
|
37
39
|
"lodash.kebabcase": "^4.1.1",
|
|
38
40
|
"mdast-util-find-and-replace": "^3.0.1",
|
|
39
|
-
"mdast-util-toc": "^5.1.0",
|
|
40
41
|
"path-browserify": "^1.0.1",
|
|
41
42
|
"process": "^0.11.10",
|
|
42
43
|
"prop-types": "^15.8.1",
|
|
43
|
-
"rehype-
|
|
44
|
+
"rehype-remark": "^10.0.0",
|
|
45
|
+
"rehype-slug": "^6.0.0",
|
|
44
46
|
"remark": "^15.0.1",
|
|
45
47
|
"remark-frontmatter": "^5.0.0",
|
|
46
48
|
"remark-gfm": "^4.0.0",
|
|
47
49
|
"remark-mdx": "^3.0.0",
|
|
48
50
|
"remark-parse": "^11.0.0",
|
|
49
|
-
"remark-rehype": "^11.1.0",
|
|
50
|
-
"remark-stringify": "^11.0.0",
|
|
51
51
|
"trim": "^1.0.1",
|
|
52
|
-
"unified": "^
|
|
52
|
+
"unified": "^11.0.4",
|
|
53
53
|
"unist-util-flatmap": "^1.0.0",
|
|
54
54
|
"unist-util-visit": "^5.0.0",
|
|
55
55
|
"util": "^0.12.5"
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"@testing-library/jest-dom": "^6.4.2",
|
|
83
83
|
"@testing-library/react": "^14",
|
|
84
84
|
"@testing-library/user-event": "^14.5.2",
|
|
85
|
+
"@types/hast": "^3.0.4",
|
|
85
86
|
"@types/jest": "^29.5.12",
|
|
86
87
|
"@types/mdast": "^4.0.3",
|
|
87
88
|
"@types/mdx": "^2.0.12",
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
"prettier": "^3.2.5",
|
|
106
107
|
"puppeteer": "^19.8.3",
|
|
107
108
|
"react-router-dom": "^6.22.3",
|
|
109
|
+
"remark-slug": "^7.0.1",
|
|
108
110
|
"sass": "^1.77.3",
|
|
109
111
|
"sass-loader": "^13.2.2",
|
|
110
112
|
"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;
|
package/components/Style.jsx
DELETED
|
@@ -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;
|