@readme/markdown 6.75.0-beta.27 → 6.75.0-beta.29

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.
@@ -0,0 +1,3 @@
1
+ import { CodeTabs } from '../../types';
2
+ declare const codeTabs: (node: CodeTabs, _: any, state: any, info: any) => any;
3
+ export default codeTabs;
@@ -0,0 +1,3 @@
1
+ import { Gemoji } from '../../types';
2
+ declare const gemoji: (node: Gemoji) => string;
3
+ export default gemoji;
@@ -0,0 +1,3 @@
1
+ import type { Image } from "mdast";
2
+ declare const image: (node: Image) => string;
3
+ export default image;
@@ -0,0 +1,8 @@
1
+ declare const compilers: {
2
+ handlers: {
3
+ emoji: (node: import("../../types").Gemoji) => string;
4
+ "code-tabs": (node: import("../../types").CodeTabs, _: any, state: any, info: any) => any;
5
+ image: (node: import("mdast").Image) => string;
6
+ };
7
+ };
8
+ export default compilers;
@@ -0,0 +1,2 @@
1
+ declare const codeTabs: () => (tree: any) => any;
2
+ export default codeTabs;
@@ -0,0 +1,3 @@
1
+ import { Root } from 'mdast';
2
+ declare const gemojiTransformer: () => (tree: Root) => Root;
3
+ export default gemojiTransformer;
@@ -0,0 +1,2 @@
1
+ declare const _default: (() => (tree: any) => void)[];
2
+ export default _default;
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.27",
5
+ "version": "6.75.0-beta.29",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",
@@ -19,20 +19,23 @@
19
19
  "release.dry": "npx semantic-release --dry-run",
20
20
  "start": "webpack serve --open --mode development --config ./webpack.dev.js",
21
21
  "test": "vitest",
22
+ "test.ui": "vitest --ui",
22
23
  "test.browser": "jest",
23
24
  "watch": "webpack --watch --progress --mode development"
24
25
  },
25
26
  "dependencies": {
26
27
  "@mdx-js/mdx": "^3.0.0",
27
- "@readme/emojis": "^5.0.0",
28
+ "@readme/emojis": "^5.1.0",
28
29
  "@readme/syntax-highlighter": "^13.0.0",
29
30
  "copy-to-clipboard": "^3.3.2",
30
31
  "core-js": "^3.36.1",
31
32
  "debug": "^4.3.4",
32
33
  "emoji-regex": "^10.2.1",
34
+ "gemoji": "^8.1.0",
33
35
  "hast-util-sanitize": "^4.0.0",
34
36
  "lodash.escape": "^4.0.1",
35
37
  "lodash.kebabcase": "^4.1.1",
38
+ "mdast-util-find-and-replace": "^3.0.1",
36
39
  "mdast-util-toc": "^5.1.0",
37
40
  "path-browserify": "^1.0.1",
38
41
  "process": "^0.11.10",
@@ -40,8 +43,11 @@
40
43
  "rehype-sanitize": "^4.0.0",
41
44
  "remark": "^15.0.1",
42
45
  "remark-frontmatter": "^5.0.0",
46
+ "remark-gfm": "^4.0.0",
43
47
  "remark-mdx": "^3.0.0",
44
48
  "remark-parse": "^11.0.0",
49
+ "remark-rehype": "^11.1.0",
50
+ "remark-stringify": "^11.0.0",
45
51
  "trim": "^1.0.1",
46
52
  "unified": "^8.4.0",
47
53
  "unist-util-flatmap": "^1.0.0",
@@ -75,8 +81,11 @@
75
81
  "@testing-library/jest-dom": "^6.4.2",
76
82
  "@testing-library/react": "^14",
77
83
  "@testing-library/user-event": "^14.5.2",
84
+ "@types/jest": "^29.5.12",
78
85
  "@types/mdast": "^4.0.3",
79
86
  "@types/mdx": "^2.0.12",
87
+ "@vitejs/plugin-react": "^4.2.1",
88
+ "@vitest/ui": "^1.5.0",
80
89
  "babel-jest": "^29.5.0",
81
90
  "babel-loader": "^9.1.2",
82
91
  "browserify-fs": "^1.0.0",
@@ -100,7 +109,7 @@
100
109
  "string.prototype.trimend": "^1.0.6",
101
110
  "terser-webpack-plugin": "^5.3.7",
102
111
  "ts-loader": "^9.4.2",
103
- "typescript": "^5.0.3",
112
+ "typescript": "^5.4.5",
104
113
  "vitest": "^1.4.0",
105
114
  "webpack": "^5.56.0",
106
115
  "webpack-cli": "^5.0.1",
@@ -1,100 +0,0 @@
1
- import copy from 'copy-to-clipboard';
2
- import { string, oneOfType, func, shape, instanceOf, arrayOf, bool } from 'prop-types';
3
- import React, { createRef, Element, Fragment } from 'react';
4
-
5
- // Only load CodeMirror in the browser, for SSR
6
- // apps. Necessary because of people like this:
7
- // https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
8
- let syntaxHighlighter;
9
- let canonicalLanguage = () => {};
10
- if (typeof window !== 'undefined') {
11
- // eslint-disable-next-line global-require
12
- syntaxHighlighter = require('@readme/syntax-highlighter').default;
13
- // eslint-disable-next-line global-require
14
- ({ canonical: canonicalLanguage } = require('@readme/syntax-highlighter'));
15
- }
16
-
17
- function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '' }) {
18
- const copyClass = `${rootClass}_copied`;
19
- const button = createRef();
20
- /* istanbul ignore next */
21
- const copier = () => {
22
- const code = codeRef.current.textContent;
23
-
24
- if (copy(code)) {
25
- const $el = button.current;
26
- $el.classList.add(copyClass);
27
- setTimeout(() => $el.classList.remove(copyClass), 1500);
28
- }
29
- };
30
- return <button ref={button} aria-label="Copy Code" className={`${rootClass} ${className}`} onClick={copier} />;
31
- }
32
-
33
- CopyCode.propTypes = {
34
- className: string,
35
- codeRef: oneOfType([func, shape({ current: instanceOf(Element) })]).isRequired,
36
- rootClass: string,
37
- };
38
-
39
- function Code(props) {
40
- const { children, className, copyButtons, lang, meta, theme } = props;
41
-
42
- const langClass = className.search(/lang(?:uage)?-\w+/) >= 0 ? className.match(/\s?lang(?:uage)?-(\w+)/)[1] : '';
43
- const language = canonicalLanguage(lang) || langClass;
44
-
45
- const codeRef = createRef();
46
-
47
- const codeOpts = {
48
- inline: !lang,
49
- tokenizeVariables: true,
50
- dark: theme === 'dark',
51
- };
52
-
53
- const codeContent =
54
- syntaxHighlighter && children ? syntaxHighlighter(children[0], language, codeOpts) : children?.[0] || '';
55
-
56
- return (
57
- <Fragment>
58
- {copyButtons && <CopyCode className="fa" codeRef={codeRef} />}
59
- <code
60
- ref={codeRef}
61
- className={['rdmd-code', `lang-${language}`, `theme-${theme}`].join(' ')}
62
- data-lang={language}
63
- name={meta}
64
- suppressHydrationWarning={true}
65
- >
66
- {codeContent}
67
- </code>
68
- </Fragment>
69
- );
70
- }
71
-
72
- function CreateCode({ copyButtons, theme }) {
73
- // eslint-disable-next-line react/display-name
74
- return props => <Code {...props} copyButtons={copyButtons} theme={theme} />;
75
- }
76
-
77
- Code.propTypes = {
78
- children: arrayOf(string),
79
- className: string,
80
- copyButtons: bool,
81
- lang: string,
82
- meta: string,
83
- theme: string,
84
- };
85
-
86
- Code.defaultProps = {
87
- className: '',
88
- copyButtons: true,
89
- lang: '',
90
- meta: '',
91
- };
92
-
93
- CreateCode.sanitize = sanitizeSchema => {
94
- // This is for code blocks class name
95
- sanitizeSchema.attributes.code = ['className', 'lang', 'meta', 'value'];
96
-
97
- return sanitizeSchema;
98
- };
99
-
100
- export default CreateCode;
@@ -1,44 +0,0 @@
1
- const Tooltip = require('@tippyjs/react').default;
2
- const PropTypes = require('prop-types');
3
- const React = require('react');
4
-
5
- const GlossaryContext = require('../../contexts/GlossaryTerms');
6
-
7
- // https://github.com/readmeio/api-explorer/blob/0dedafcf71102feedaa4145040d3f57d79d95752/packages/api-explorer/src/lib/replace-vars.js#L8
8
- function GlossaryItem({ term, terms }) {
9
- const foundTerm = terms.find(i => term.toLowerCase() === i.term.toLowerCase());
10
-
11
- if (!foundTerm) return <span>{term}</span>;
12
-
13
- return (
14
- <Tooltip
15
- content={
16
- <div className="GlossaryItem-tooltip-content">
17
- <strong className="GlossaryItem-term">{foundTerm.term}</strong> - {foundTerm.definition}
18
- </div>
19
- }
20
- offset={[-5, 5]}
21
- placement="bottom-start"
22
- >
23
- <span className="GlossaryItem-trigger">{term}</span>
24
- </Tooltip>
25
- );
26
- }
27
-
28
- GlossaryItem.propTypes = {
29
- term: PropTypes.string.isRequired,
30
- terms: PropTypes.arrayOf(
31
- PropTypes.shape({
32
- definition: PropTypes.string.isRequired,
33
- term: PropTypes.string.isRequired,
34
- })
35
- ).isRequired,
36
- };
37
-
38
- // eslint-disable-next-line react/display-name
39
- module.exports = props => (
40
- <GlossaryContext.Consumer>{terms => terms && <GlossaryItem {...props} terms={terms} />}</GlossaryContext.Consumer>
41
- );
42
-
43
- module.exports.GlossaryItem = GlossaryItem;
44
- module.exports.GlossaryContext = GlossaryContext;
@@ -1,111 +0,0 @@
1
- /* eslint-disable no-param-reassign, react/jsx-props-no-spreading, no-fallthrough */
2
-
3
- const PropTypes = require('prop-types');
4
- const React = require('react');
5
-
6
- class Image extends React.Component {
7
- constructor(props) {
8
- super(props);
9
-
10
- this.state = {
11
- lightbox: false,
12
- };
13
-
14
- this.toggle = this.toggle.bind(this);
15
- this.handleKey = this.handleKey.bind(this);
16
-
17
- this.isEmoji = props.className === 'emoji';
18
- }
19
-
20
- toggle(toState) {
21
- if (this.props.className === 'emoji') return;
22
-
23
- if (typeof toState === 'undefined') toState = !this.state.lightbox;
24
-
25
- this.setState({ lightbox: toState });
26
- }
27
-
28
- handleKey(e) {
29
- let { key, metaKey: cmd } = e;
30
-
31
- cmd = cmd ? 'cmd+' : '';
32
- key = `${cmd}${key.toLowerCase()}`;
33
-
34
- switch (key) {
35
- case 'cmd+.':
36
- case 'escape':
37
- // CLOSE
38
- this.toggle(false);
39
- break;
40
- case ' ':
41
- case 'enter':
42
- // OPEN
43
- if (!this.state.open) this.toggle(true);
44
- e.preventDefault();
45
- default:
46
- }
47
- }
48
-
49
- render() {
50
- const { props } = this;
51
-
52
- const { alt, lazy = true } = props;
53
-
54
- if (this.isEmoji) {
55
- return <img {...props} alt={alt} loading={lazy ? 'lazy' : ''} />;
56
- }
57
-
58
- const align = props.align === 'center' ? 'middle' : props.align;
59
-
60
- return (
61
- <span
62
- aria-label={alt}
63
- className={`img lightbox ${this.state.lightbox ? 'open' : 'closed'}`}
64
- onClick={() => this.toggle()}
65
- onKeyDown={this.handleKey}
66
- role={'button'}
67
- tabIndex={0}
68
- >
69
- <span className="lightbox-inner">
70
- <img {...props} align={align} alt={alt} loading={lazy ? 'lazy' : ''} />
71
- </span>
72
- </span>
73
- );
74
- }
75
- }
76
-
77
- Image.propTypes = {
78
- align: PropTypes.string,
79
- alt: PropTypes.string,
80
- caption: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
81
- className: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
82
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
83
- lazy: PropTypes.bool,
84
- src: PropTypes.string.isRequired,
85
- title: PropTypes.string,
86
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
87
- };
88
-
89
- Image.defaultProps = {
90
- align: '',
91
- alt: '',
92
- caption: '',
93
- height: 'auto',
94
- src: '',
95
- title: '',
96
- width: 'auto',
97
- };
98
-
99
- Image.sanitize = sanitizeSchema => {
100
- sanitizeSchema.attributes.img = ['className', 'title', 'alt', 'width', 'height', 'align', 'src', 'longDesc'];
101
-
102
- return sanitizeSchema;
103
- };
104
-
105
- const CreateImage =
106
- ({ lazyImages }) =>
107
- // eslint-disable-next-line react/display-name
108
- props =>
109
- <Image lazy={lazyImages} {...props} />;
110
-
111
- module.exports = CreateImage;
File without changes