@readme/markdown 6.75.0-beta.62 → 6.75.0-beta.64
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/Image/index.tsx +5 -2
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/main.js +189 -168
- package/dist/main.node.js +189 -168
- package/dist/processor/transform/code-tabs.d.ts +2 -1
- package/dist/processor/transform/images.d.ts +1 -1
- package/dist/processor/transform/variables.d.ts +3 -1
- package/package.json +1 -1
|
@@ -11,10 +11,10 @@ interface ImageProps {
|
|
|
11
11
|
title?: string;
|
|
12
12
|
width?: string;
|
|
13
13
|
lazy?: boolean;
|
|
14
|
+
children?: [React.ReactElement];
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const Image = (Props: ImageProps) => {
|
|
17
|
-
const [lightbox, setLightbox] = React.useState(false);
|
|
18
18
|
const {
|
|
19
19
|
align = '',
|
|
20
20
|
alt = '',
|
|
@@ -26,8 +26,11 @@ const Image = (Props: ImageProps) => {
|
|
|
26
26
|
title = '',
|
|
27
27
|
width = 'auto',
|
|
28
28
|
lazy = false,
|
|
29
|
+
children,
|
|
29
30
|
} = Props;
|
|
30
31
|
|
|
32
|
+
const [lightbox, setLightbox] = React.useState(false);
|
|
33
|
+
|
|
31
34
|
if (className === 'emoji') {
|
|
32
35
|
return <img src={src} width={width} height={height} title={title} alt={alt} loading={lazy ? 'lazy' : 'eager'} />;
|
|
33
36
|
}
|
|
@@ -76,7 +79,7 @@ const Image = (Props: ImageProps) => {
|
|
|
76
79
|
alt={alt}
|
|
77
80
|
loading={lazy ? 'lazy' : 'eager'}
|
|
78
81
|
/>
|
|
79
|
-
<figcaption>{caption}</figcaption>
|
|
82
|
+
<figcaption>{children || caption}</figcaption>
|
|
80
83
|
</figure>
|
|
81
84
|
</span>
|
|
82
85
|
</span>
|
package/dist/main.js
CHANGED
|
@@ -14444,8 +14444,8 @@ const CreateHeading = (depth) => (props) => external_amd_react_commonjs_react_co
|
|
|
14444
14444
|
;// CONCATENATED MODULE: ./components/Image/index.tsx
|
|
14445
14445
|
|
|
14446
14446
|
const Image = (Props) => {
|
|
14447
|
+
const { align = '', alt = '', border = false, caption, className = '', height = 'auto', src, title = '', width = 'auto', lazy = false, children, } = Props;
|
|
14447
14448
|
const [lightbox, setLightbox] = external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useState(false);
|
|
14448
|
-
const { align = '', alt = '', border = false, caption, className = '', height = 'auto', src, title = '', width = 'auto', lazy = false, } = Props;
|
|
14449
14449
|
if (className === 'emoji') {
|
|
14450
14450
|
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, alt: alt, loading: lazy ? 'lazy' : 'eager' });
|
|
14451
14451
|
}
|
|
@@ -14476,7 +14476,7 @@ const Image = (Props) => {
|
|
|
14476
14476
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
|
|
14477
14477
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
|
|
14478
14478
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-center ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }),
|
|
14479
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, caption)))));
|
|
14479
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, children || caption)))));
|
|
14480
14480
|
}
|
|
14481
14481
|
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", null,
|
|
14482
14482
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
@@ -48474,7 +48474,8 @@ const calloutTransformer = () => {
|
|
|
48474
48474
|
;// CONCATENATED MODULE: ./processor/transform/code-tabs.ts
|
|
48475
48475
|
|
|
48476
48476
|
|
|
48477
|
-
const
|
|
48477
|
+
const isCode = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'code';
|
|
48478
|
+
const codeTabsTransformer = () => (tree) => {
|
|
48478
48479
|
visit(tree, 'code', (node) => {
|
|
48479
48480
|
const { lang, meta, value } = node;
|
|
48480
48481
|
node.data = {
|
|
@@ -48489,7 +48490,7 @@ const codeTabsTransformer = () => tree => {
|
|
|
48489
48490
|
let walker = index + 1;
|
|
48490
48491
|
while (walker <= length) {
|
|
48491
48492
|
const sibling = parent.children[walker];
|
|
48492
|
-
if ((sibling
|
|
48493
|
+
if (!isCode(sibling))
|
|
48493
48494
|
break;
|
|
48494
48495
|
const olderSibling = parent.children[walker - 1];
|
|
48495
48496
|
if (olderSibling.position.end.offset + sibling.position.start.column !== sibling.position.start.offset)
|
|
@@ -48549,31 +48550,159 @@ const embedTransformer = () => {
|
|
|
48549
48550
|
};
|
|
48550
48551
|
/* harmony default export */ const transform_embeds = (embedTransformer);
|
|
48551
48552
|
|
|
48553
|
+
;// CONCATENATED MODULE: ./processor/utils.ts
|
|
48554
|
+
/**
|
|
48555
|
+
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
48556
|
+
* This currently sets all the values to a string since we process/compile the MDX on the fly
|
|
48557
|
+
* through the editor, and it'll throw errors over malformed JSX. TODO: fix this.
|
|
48558
|
+
*
|
|
48559
|
+
* @template T
|
|
48560
|
+
* @param {Node} node
|
|
48561
|
+
* @returns {string} formatted hProperties as JSX attributes
|
|
48562
|
+
*/
|
|
48563
|
+
const formatHProps = (node) => {
|
|
48564
|
+
const hProps = getHProps(node);
|
|
48565
|
+
const hPropKeys = getHPropKeys(node);
|
|
48566
|
+
return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
|
|
48567
|
+
};
|
|
48568
|
+
/**
|
|
48569
|
+
* Returns the hProperties of a node.
|
|
48570
|
+
*
|
|
48571
|
+
* @template T
|
|
48572
|
+
* @param {Node} node
|
|
48573
|
+
* @returns {T} hProperties
|
|
48574
|
+
*/
|
|
48575
|
+
const getHProps = (node) => {
|
|
48576
|
+
var _a;
|
|
48577
|
+
const hProps = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
|
|
48578
|
+
return hProps;
|
|
48579
|
+
};
|
|
48580
|
+
/**
|
|
48581
|
+
* Returns array of hProperty keys.
|
|
48582
|
+
*
|
|
48583
|
+
* @template T
|
|
48584
|
+
* @param {Node} node
|
|
48585
|
+
* @returns {Array} array of hProperty keys
|
|
48586
|
+
*/
|
|
48587
|
+
const getHPropKeys = (node) => {
|
|
48588
|
+
const hProps = getHProps(node);
|
|
48589
|
+
return Object.keys(hProps) || [];
|
|
48590
|
+
};
|
|
48591
|
+
/**
|
|
48592
|
+
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
48593
|
+
*
|
|
48594
|
+
* @template T
|
|
48595
|
+
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
48596
|
+
* @returns {T} object of hProperties
|
|
48597
|
+
*/
|
|
48598
|
+
const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
|
|
48599
|
+
if ('name' in attr) {
|
|
48600
|
+
memo[attr.name] = attr.value;
|
|
48601
|
+
}
|
|
48602
|
+
return memo;
|
|
48603
|
+
}, {});
|
|
48604
|
+
/**
|
|
48605
|
+
* Gets the children of an MDX element and returns them as an array of Text nodes.
|
|
48606
|
+
* Currently only being used by the HTML Block component, which only expects a single text node.
|
|
48607
|
+
*
|
|
48608
|
+
* @template T
|
|
48609
|
+
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
48610
|
+
* @returns {Array} array of child text nodes
|
|
48611
|
+
*/
|
|
48612
|
+
const getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
|
|
48613
|
+
memo[i] = {
|
|
48614
|
+
type: 'text',
|
|
48615
|
+
value: child.value,
|
|
48616
|
+
position: child.position,
|
|
48617
|
+
};
|
|
48618
|
+
return memo;
|
|
48619
|
+
}, []);
|
|
48620
|
+
/**
|
|
48621
|
+
* Tests if a node is an MDX element.
|
|
48622
|
+
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
48623
|
+
*
|
|
48624
|
+
* @param {Node} node
|
|
48625
|
+
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
48626
|
+
*/
|
|
48627
|
+
const isMDXElement = (node) => {
|
|
48628
|
+
return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
|
|
48629
|
+
};
|
|
48630
|
+
/**
|
|
48631
|
+
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
48632
|
+
* and unindents the HTML.
|
|
48633
|
+
*
|
|
48634
|
+
* @param {string} html
|
|
48635
|
+
* @returns {string} formatted HTML
|
|
48636
|
+
*/
|
|
48637
|
+
const formatHTML = (html) => {
|
|
48638
|
+
// Remove leading/trailing backticks if present, since they're used to keep the HTML
|
|
48639
|
+
// from being parsed prematurely
|
|
48640
|
+
if (html.startsWith('`') && html.endsWith('`')) {
|
|
48641
|
+
html = html.slice(1, -1);
|
|
48642
|
+
}
|
|
48643
|
+
// Removes the leading/trailing newlines
|
|
48644
|
+
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
48645
|
+
// // Get the number of spaces in the first line to determine the tab size
|
|
48646
|
+
// const tab = cleaned.match(/^\s*/)[0].length;
|
|
48647
|
+
// // Remove the first indentation level from each line
|
|
48648
|
+
// const tabRegex = new RegExp(`^\\s{${tab}}`, 'gm');
|
|
48649
|
+
// const unindented = cleaned.replace(tabRegex, '');
|
|
48650
|
+
return cleaned;
|
|
48651
|
+
};
|
|
48652
|
+
/**
|
|
48653
|
+
* Reformat HTML for the markdown/mdx by adding an indentation to each line. This assures that the
|
|
48654
|
+
* HTML is indentend properly within the HTMLBlock component when rendered in the markdown/mdx.
|
|
48655
|
+
*
|
|
48656
|
+
* @param {string} html
|
|
48657
|
+
* @param {number} [indent=2]
|
|
48658
|
+
* @returns {string} re-formatted HTML
|
|
48659
|
+
*/
|
|
48660
|
+
const reformatHTML = (html, indent = 2) => {
|
|
48661
|
+
// Remove leading/trailing newlines
|
|
48662
|
+
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
48663
|
+
// // Create a tab/indent with the specified number of spaces
|
|
48664
|
+
// const tab = ' '.repeat(indent);
|
|
48665
|
+
// // Indent each line of the HTML (converts to an array, indents each line, then joins back)
|
|
48666
|
+
// const indented = cleaned.split('\n').map((line: string) => `${tab}${line}`).join('\n');
|
|
48667
|
+
return cleaned;
|
|
48668
|
+
};
|
|
48669
|
+
|
|
48552
48670
|
;// CONCATENATED MODULE: ./processor/transform/images.ts
|
|
48553
48671
|
|
|
48554
48672
|
|
|
48555
|
-
|
|
48556
|
-
|
|
48557
|
-
|
|
48558
|
-
|
|
48559
|
-
|
|
48560
|
-
|
|
48561
|
-
|
|
48562
|
-
|
|
48563
|
-
|
|
48564
|
-
|
|
48565
|
-
|
|
48566
|
-
|
|
48567
|
-
|
|
48568
|
-
|
|
48569
|
-
|
|
48570
|
-
|
|
48571
|
-
|
|
48572
|
-
|
|
48573
|
-
|
|
48574
|
-
|
|
48575
|
-
|
|
48576
|
-
|
|
48673
|
+
|
|
48674
|
+
|
|
48675
|
+
const imageTransformer = () => (tree) => {
|
|
48676
|
+
visit(tree, 'paragraph', (node, i, parent) => {
|
|
48677
|
+
var _a;
|
|
48678
|
+
// check if inline
|
|
48679
|
+
if (parent.type !== 'root' ||
|
|
48680
|
+
((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 ||
|
|
48681
|
+
node.children[0].type !== 'image')
|
|
48682
|
+
return;
|
|
48683
|
+
const [{ alt, url, title }] = node.children;
|
|
48684
|
+
const newNode = {
|
|
48685
|
+
type: NodeTypes.imageBlock,
|
|
48686
|
+
alt,
|
|
48687
|
+
title,
|
|
48688
|
+
url,
|
|
48689
|
+
children: [],
|
|
48690
|
+
data: {
|
|
48691
|
+
hName: 'img',
|
|
48692
|
+
hProperties: Object.assign(Object.assign(Object.assign({}, (alt && { alt })), { src: url }), (title && { title })),
|
|
48693
|
+
},
|
|
48694
|
+
position: node.position,
|
|
48695
|
+
};
|
|
48696
|
+
parent.children.splice(i, 1, newNode);
|
|
48697
|
+
});
|
|
48698
|
+
const isImage = (node) => node.name === 'Image';
|
|
48699
|
+
visit(tree, isImage, (node) => {
|
|
48700
|
+
const attrs = getAttrs(node);
|
|
48701
|
+
if (attrs.caption) {
|
|
48702
|
+
node.children = lib_mdast(attrs.caption).children;
|
|
48703
|
+
}
|
|
48704
|
+
});
|
|
48705
|
+
return tree;
|
|
48577
48706
|
};
|
|
48578
48707
|
/* harmony default export */ const transform_images = (imageTransformer);
|
|
48579
48708
|
|
|
@@ -65563,6 +65692,7 @@ const gemojiTransformer = () => (tree) => {
|
|
|
65563
65692
|
|
|
65564
65693
|
;// CONCATENATED MODULE: ./processor/transform/inject-components.ts
|
|
65565
65694
|
|
|
65695
|
+
|
|
65566
65696
|
const inject = ({ components } = {}) => (node, index, parent) => {
|
|
65567
65697
|
if (!(node.name in components))
|
|
65568
65698
|
return;
|
|
@@ -65570,140 +65700,23 @@ const inject = ({ components } = {}) => (node, index, parent) => {
|
|
|
65570
65700
|
parent.children.splice(index, children.length, ...children);
|
|
65571
65701
|
};
|
|
65572
65702
|
const injectComponents = (opts) => () => tree => {
|
|
65573
|
-
visit(tree,
|
|
65574
|
-
visit(tree, 'mdxJsxTextElement', inject(opts));
|
|
65703
|
+
visit(tree, isMDXElement, inject(opts));
|
|
65575
65704
|
return tree;
|
|
65576
65705
|
};
|
|
65577
65706
|
/* harmony default export */ const inject_components = (injectComponents);
|
|
65578
65707
|
|
|
65579
|
-
;// CONCATENATED MODULE: ./processor/utils.ts
|
|
65580
|
-
/**
|
|
65581
|
-
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
65582
|
-
* This currently sets all the values to a string since we process/compile the MDX on the fly
|
|
65583
|
-
* through the editor, and it'll throw errors over malformed JSX. TODO: fix this.
|
|
65584
|
-
*
|
|
65585
|
-
* @template T
|
|
65586
|
-
* @param {Node} node
|
|
65587
|
-
* @returns {string} formatted hProperties as JSX attributes
|
|
65588
|
-
*/
|
|
65589
|
-
const formatHProps = (node) => {
|
|
65590
|
-
const hProps = getHProps(node);
|
|
65591
|
-
const hPropKeys = getHPropKeys(node);
|
|
65592
|
-
return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
|
|
65593
|
-
};
|
|
65594
|
-
/**
|
|
65595
|
-
* Returns the hProperties of a node.
|
|
65596
|
-
*
|
|
65597
|
-
* @template T
|
|
65598
|
-
* @param {Node} node
|
|
65599
|
-
* @returns {T} hProperties
|
|
65600
|
-
*/
|
|
65601
|
-
const getHProps = (node) => {
|
|
65602
|
-
var _a;
|
|
65603
|
-
const hProps = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
|
|
65604
|
-
return hProps;
|
|
65605
|
-
};
|
|
65606
|
-
/**
|
|
65607
|
-
* Returns array of hProperty keys.
|
|
65608
|
-
*
|
|
65609
|
-
* @template T
|
|
65610
|
-
* @param {Node} node
|
|
65611
|
-
* @returns {Array} array of hProperty keys
|
|
65612
|
-
*/
|
|
65613
|
-
const getHPropKeys = (node) => {
|
|
65614
|
-
const hProps = getHProps(node);
|
|
65615
|
-
return Object.keys(hProps) || [];
|
|
65616
|
-
};
|
|
65617
|
-
/**
|
|
65618
|
-
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
65619
|
-
*
|
|
65620
|
-
* @template T
|
|
65621
|
-
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
65622
|
-
* @returns {T} object of hProperties
|
|
65623
|
-
*/
|
|
65624
|
-
const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
|
|
65625
|
-
if ('name' in attr) {
|
|
65626
|
-
memo[attr.name] = attr.value;
|
|
65627
|
-
}
|
|
65628
|
-
return memo;
|
|
65629
|
-
}, {});
|
|
65630
|
-
/**
|
|
65631
|
-
* Gets the children of an MDX element and returns them as an array of Text nodes.
|
|
65632
|
-
* Currently only being used by the HTML Block component, which only expects a single text node.
|
|
65633
|
-
*
|
|
65634
|
-
* @template T
|
|
65635
|
-
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
65636
|
-
* @returns {Array} array of child text nodes
|
|
65637
|
-
*/
|
|
65638
|
-
const getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
|
|
65639
|
-
memo[i] = {
|
|
65640
|
-
type: 'text',
|
|
65641
|
-
value: child.value,
|
|
65642
|
-
position: child.position,
|
|
65643
|
-
};
|
|
65644
|
-
return memo;
|
|
65645
|
-
}, []);
|
|
65646
|
-
/**
|
|
65647
|
-
* Tests if a node is an MDX element.
|
|
65648
|
-
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
65649
|
-
*
|
|
65650
|
-
* @param {Node} node
|
|
65651
|
-
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
65652
|
-
*/
|
|
65653
|
-
const isMDXElement = (node) => {
|
|
65654
|
-
return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
|
|
65655
|
-
};
|
|
65656
|
-
/**
|
|
65657
|
-
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
65658
|
-
* and unindents the HTML.
|
|
65659
|
-
*
|
|
65660
|
-
* @param {string} html
|
|
65661
|
-
* @returns {string} formatted HTML
|
|
65662
|
-
*/
|
|
65663
|
-
const formatHTML = (html) => {
|
|
65664
|
-
// Remove leading/trailing backticks if present, since they're used to keep the HTML
|
|
65665
|
-
// from being parsed prematurely
|
|
65666
|
-
if (html.startsWith('`') && html.endsWith('`')) {
|
|
65667
|
-
html = html.slice(1, -1);
|
|
65668
|
-
}
|
|
65669
|
-
// Removes the leading/trailing newlines
|
|
65670
|
-
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
65671
|
-
// // Get the number of spaces in the first line to determine the tab size
|
|
65672
|
-
// const tab = cleaned.match(/^\s*/)[0].length;
|
|
65673
|
-
// // Remove the first indentation level from each line
|
|
65674
|
-
// const tabRegex = new RegExp(`^\\s{${tab}}`, 'gm');
|
|
65675
|
-
// const unindented = cleaned.replace(tabRegex, '');
|
|
65676
|
-
return cleaned;
|
|
65677
|
-
};
|
|
65678
|
-
/**
|
|
65679
|
-
* Reformat HTML for the markdown/mdx by adding an indentation to each line. This assures that the
|
|
65680
|
-
* HTML is indentend properly within the HTMLBlock component when rendered in the markdown/mdx.
|
|
65681
|
-
*
|
|
65682
|
-
* @param {string} html
|
|
65683
|
-
* @param {number} [indent=2]
|
|
65684
|
-
* @returns {string} re-formatted HTML
|
|
65685
|
-
*/
|
|
65686
|
-
const reformatHTML = (html, indent = 2) => {
|
|
65687
|
-
// Remove leading/trailing newlines
|
|
65688
|
-
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
65689
|
-
// // Create a tab/indent with the specified number of spaces
|
|
65690
|
-
// const tab = ' '.repeat(indent);
|
|
65691
|
-
// // Indent each line of the HTML (converts to an array, indents each line, then joins back)
|
|
65692
|
-
// const indented = cleaned.split('\n').map((line: string) => `${tab}${line}`).join('\n');
|
|
65693
|
-
return cleaned;
|
|
65694
|
-
};
|
|
65695
|
-
|
|
65696
65708
|
;// CONCATENATED MODULE: ./processor/transform/readme-components.ts
|
|
65697
65709
|
|
|
65698
65710
|
|
|
65699
65711
|
|
|
65712
|
+
|
|
65700
65713
|
const readme_components_types = {
|
|
65701
65714
|
Callout: NodeTypes['callout'],
|
|
65702
65715
|
Code: 'code',
|
|
65703
65716
|
CodeTabs: NodeTypes['codeTabs'],
|
|
65704
65717
|
EmbedBlock: NodeTypes['embed-block'],
|
|
65705
65718
|
Glossary: NodeTypes['glossary'],
|
|
65706
|
-
ImageBlock: NodeTypes
|
|
65719
|
+
ImageBlock: NodeTypes.imageBlock,
|
|
65707
65720
|
HTMLBlock: NodeTypes.htmlBlock,
|
|
65708
65721
|
Table: 'table',
|
|
65709
65722
|
Variable: NodeTypes['variable'],
|
|
@@ -65736,6 +65749,7 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
|
|
|
65736
65749
|
const mdNode = {
|
|
65737
65750
|
alt,
|
|
65738
65751
|
position,
|
|
65752
|
+
children: attrs.caption ? lib_mdast(attrs.caption).children : node.children,
|
|
65739
65753
|
title,
|
|
65740
65754
|
type: NodeTypes.imageBlock,
|
|
65741
65755
|
url: url || attrs.src,
|
|
@@ -65851,26 +65865,39 @@ const readmeToMdx = () => tree => {
|
|
|
65851
65865
|
|
|
65852
65866
|
;// CONCATENATED MODULE: ./processor/transform/variables.ts
|
|
65853
65867
|
|
|
65854
|
-
|
|
65868
|
+
|
|
65869
|
+
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
65855
65870
|
visit(tree, (node, index, parent) => {
|
|
65856
65871
|
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
65857
65872
|
return;
|
|
65858
65873
|
const match = node.value.match(/^user\.(?<value>.*)$/);
|
|
65859
65874
|
if (!match)
|
|
65860
65875
|
return;
|
|
65861
|
-
let variable =
|
|
65862
|
-
|
|
65863
|
-
|
|
65864
|
-
|
|
65865
|
-
|
|
65866
|
-
|
|
65867
|
-
|
|
65868
|
-
|
|
65876
|
+
let variable = asMdx
|
|
65877
|
+
? {
|
|
65878
|
+
type: 'mdxJsxTextElement',
|
|
65879
|
+
name: 'Variable',
|
|
65880
|
+
attributes: [
|
|
65881
|
+
{
|
|
65882
|
+
type: 'mdxJsxAttribute',
|
|
65883
|
+
name: 'name',
|
|
65884
|
+
value: match.groups.value,
|
|
65885
|
+
},
|
|
65886
|
+
],
|
|
65887
|
+
children: [],
|
|
65888
|
+
position: node.position,
|
|
65889
|
+
}
|
|
65890
|
+
: {
|
|
65891
|
+
type: NodeTypes.variable,
|
|
65892
|
+
data: {
|
|
65893
|
+
hName: 'Variable',
|
|
65894
|
+
hProperties: {
|
|
65895
|
+
name: match.groups.value,
|
|
65896
|
+
},
|
|
65869
65897
|
},
|
|
65870
|
-
|
|
65871
|
-
|
|
65872
|
-
|
|
65873
|
-
};
|
|
65898
|
+
value: `{${node.value}}`,
|
|
65899
|
+
position: node.position,
|
|
65900
|
+
};
|
|
65874
65901
|
parent.children.splice(index, 1, variable);
|
|
65875
65902
|
});
|
|
65876
65903
|
return tree;
|
|
@@ -65888,14 +65915,7 @@ const variables = () => tree => {
|
|
|
65888
65915
|
|
|
65889
65916
|
|
|
65890
65917
|
|
|
65891
|
-
/* harmony default export */ const transform = ([
|
|
65892
|
-
callouts,
|
|
65893
|
-
code_tabs,
|
|
65894
|
-
transform_embeds,
|
|
65895
|
-
transform_images,
|
|
65896
|
-
gemoji_,
|
|
65897
|
-
transform_variables,
|
|
65898
|
-
]);
|
|
65918
|
+
/* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, transform_images, gemoji_]);
|
|
65899
65919
|
|
|
65900
65920
|
;// CONCATENATED MODULE: ./lib/ast-processor.ts
|
|
65901
65921
|
|
|
@@ -65907,6 +65927,7 @@ const remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform];
|
|
|
65907
65927
|
const astProcessor = (opts = { components: {} }) => remark()
|
|
65908
65928
|
.use(remarkMdx)
|
|
65909
65929
|
.use(remarkPlugins)
|
|
65930
|
+
.use(transform_variables, { asMdx: false })
|
|
65910
65931
|
.use(readme_components({ components: opts.components }));
|
|
65911
65932
|
/* harmony default export */ const ast_processor = (astProcessor);
|
|
65912
65933
|
|
|
@@ -78547,7 +78568,7 @@ var compile_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
78547
78568
|
|
|
78548
78569
|
|
|
78549
78570
|
|
|
78550
|
-
const compile_remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform];
|
|
78571
|
+
const compile_remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform, transform_variables];
|
|
78551
78572
|
const compile_compile = (text, _a = {}) => {
|
|
78552
78573
|
var { components } = _a, opts = compile_rest(_a, ["components"]);
|
|
78553
78574
|
try {
|
package/dist/main.node.js
CHANGED
|
@@ -14334,8 +14334,8 @@ const CreateHeading = (depth) => (props) => external_amd_react_commonjs_react_co
|
|
|
14334
14334
|
;// CONCATENATED MODULE: ./components/Image/index.tsx
|
|
14335
14335
|
|
|
14336
14336
|
const Image = (Props) => {
|
|
14337
|
+
const { align = '', alt = '', border = false, caption, className = '', height = 'auto', src, title = '', width = 'auto', lazy = false, children, } = Props;
|
|
14337
14338
|
const [lightbox, setLightbox] = external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useState(false);
|
|
14338
|
-
const { align = '', alt = '', border = false, caption, className = '', height = 'auto', src, title = '', width = 'auto', lazy = false, } = Props;
|
|
14339
14339
|
if (className === 'emoji') {
|
|
14340
14340
|
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, alt: alt, loading: lazy ? 'lazy' : 'eager' });
|
|
14341
14341
|
}
|
|
@@ -14366,7 +14366,7 @@ const Image = (Props) => {
|
|
|
14366
14366
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { className: "lightbox-inner" },
|
|
14367
14367
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figure", null,
|
|
14368
14368
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("img", { src: src, width: width, height: height, title: title, className: `img img-align-center ${border ? 'border' : ''}`, alt: alt, loading: lazy ? 'lazy' : 'eager' }),
|
|
14369
|
-
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, caption)))));
|
|
14369
|
+
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("figcaption", null, children || caption)))));
|
|
14370
14370
|
}
|
|
14371
14371
|
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("p", null,
|
|
14372
14372
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.createElement("span", { "aria-label": alt, className: `img lightbox ${lightbox ? 'open' : 'closed'}`, onClick: toggle, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 },
|
|
@@ -49927,7 +49927,8 @@ const calloutTransformer = () => {
|
|
|
49927
49927
|
;// CONCATENATED MODULE: ./processor/transform/code-tabs.ts
|
|
49928
49928
|
|
|
49929
49929
|
|
|
49930
|
-
const
|
|
49930
|
+
const isCode = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'code';
|
|
49931
|
+
const codeTabsTransformer = () => (tree) => {
|
|
49931
49932
|
visit(tree, 'code', (node) => {
|
|
49932
49933
|
const { lang, meta, value } = node;
|
|
49933
49934
|
node.data = {
|
|
@@ -49942,7 +49943,7 @@ const codeTabsTransformer = () => tree => {
|
|
|
49942
49943
|
let walker = index + 1;
|
|
49943
49944
|
while (walker <= length) {
|
|
49944
49945
|
const sibling = parent.children[walker];
|
|
49945
|
-
if ((sibling
|
|
49946
|
+
if (!isCode(sibling))
|
|
49946
49947
|
break;
|
|
49947
49948
|
const olderSibling = parent.children[walker - 1];
|
|
49948
49949
|
if (olderSibling.position.end.offset + sibling.position.start.column !== sibling.position.start.offset)
|
|
@@ -50002,31 +50003,159 @@ const embedTransformer = () => {
|
|
|
50002
50003
|
};
|
|
50003
50004
|
/* harmony default export */ const transform_embeds = (embedTransformer);
|
|
50004
50005
|
|
|
50006
|
+
;// CONCATENATED MODULE: ./processor/utils.ts
|
|
50007
|
+
/**
|
|
50008
|
+
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
50009
|
+
* This currently sets all the values to a string since we process/compile the MDX on the fly
|
|
50010
|
+
* through the editor, and it'll throw errors over malformed JSX. TODO: fix this.
|
|
50011
|
+
*
|
|
50012
|
+
* @template T
|
|
50013
|
+
* @param {Node} node
|
|
50014
|
+
* @returns {string} formatted hProperties as JSX attributes
|
|
50015
|
+
*/
|
|
50016
|
+
const formatHProps = (node) => {
|
|
50017
|
+
const hProps = getHProps(node);
|
|
50018
|
+
const hPropKeys = getHPropKeys(node);
|
|
50019
|
+
return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
|
|
50020
|
+
};
|
|
50021
|
+
/**
|
|
50022
|
+
* Returns the hProperties of a node.
|
|
50023
|
+
*
|
|
50024
|
+
* @template T
|
|
50025
|
+
* @param {Node} node
|
|
50026
|
+
* @returns {T} hProperties
|
|
50027
|
+
*/
|
|
50028
|
+
const getHProps = (node) => {
|
|
50029
|
+
var _a;
|
|
50030
|
+
const hProps = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
|
|
50031
|
+
return hProps;
|
|
50032
|
+
};
|
|
50033
|
+
/**
|
|
50034
|
+
* Returns array of hProperty keys.
|
|
50035
|
+
*
|
|
50036
|
+
* @template T
|
|
50037
|
+
* @param {Node} node
|
|
50038
|
+
* @returns {Array} array of hProperty keys
|
|
50039
|
+
*/
|
|
50040
|
+
const getHPropKeys = (node) => {
|
|
50041
|
+
const hProps = getHProps(node);
|
|
50042
|
+
return Object.keys(hProps) || [];
|
|
50043
|
+
};
|
|
50044
|
+
/**
|
|
50045
|
+
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
50046
|
+
*
|
|
50047
|
+
* @template T
|
|
50048
|
+
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
50049
|
+
* @returns {T} object of hProperties
|
|
50050
|
+
*/
|
|
50051
|
+
const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
|
|
50052
|
+
if ('name' in attr) {
|
|
50053
|
+
memo[attr.name] = attr.value;
|
|
50054
|
+
}
|
|
50055
|
+
return memo;
|
|
50056
|
+
}, {});
|
|
50057
|
+
/**
|
|
50058
|
+
* Gets the children of an MDX element and returns them as an array of Text nodes.
|
|
50059
|
+
* Currently only being used by the HTML Block component, which only expects a single text node.
|
|
50060
|
+
*
|
|
50061
|
+
* @template T
|
|
50062
|
+
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
50063
|
+
* @returns {Array} array of child text nodes
|
|
50064
|
+
*/
|
|
50065
|
+
const utils_getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
|
|
50066
|
+
memo[i] = {
|
|
50067
|
+
type: 'text',
|
|
50068
|
+
value: child.value,
|
|
50069
|
+
position: child.position,
|
|
50070
|
+
};
|
|
50071
|
+
return memo;
|
|
50072
|
+
}, []);
|
|
50073
|
+
/**
|
|
50074
|
+
* Tests if a node is an MDX element.
|
|
50075
|
+
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
50076
|
+
*
|
|
50077
|
+
* @param {Node} node
|
|
50078
|
+
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
50079
|
+
*/
|
|
50080
|
+
const isMDXElement = (node) => {
|
|
50081
|
+
return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
|
|
50082
|
+
};
|
|
50083
|
+
/**
|
|
50084
|
+
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
50085
|
+
* and unindents the HTML.
|
|
50086
|
+
*
|
|
50087
|
+
* @param {string} html
|
|
50088
|
+
* @returns {string} formatted HTML
|
|
50089
|
+
*/
|
|
50090
|
+
const formatHTML = (html) => {
|
|
50091
|
+
// Remove leading/trailing backticks if present, since they're used to keep the HTML
|
|
50092
|
+
// from being parsed prematurely
|
|
50093
|
+
if (html.startsWith('`') && html.endsWith('`')) {
|
|
50094
|
+
html = html.slice(1, -1);
|
|
50095
|
+
}
|
|
50096
|
+
// Removes the leading/trailing newlines
|
|
50097
|
+
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
50098
|
+
// // Get the number of spaces in the first line to determine the tab size
|
|
50099
|
+
// const tab = cleaned.match(/^\s*/)[0].length;
|
|
50100
|
+
// // Remove the first indentation level from each line
|
|
50101
|
+
// const tabRegex = new RegExp(`^\\s{${tab}}`, 'gm');
|
|
50102
|
+
// const unindented = cleaned.replace(tabRegex, '');
|
|
50103
|
+
return cleaned;
|
|
50104
|
+
};
|
|
50105
|
+
/**
|
|
50106
|
+
* Reformat HTML for the markdown/mdx by adding an indentation to each line. This assures that the
|
|
50107
|
+
* HTML is indentend properly within the HTMLBlock component when rendered in the markdown/mdx.
|
|
50108
|
+
*
|
|
50109
|
+
* @param {string} html
|
|
50110
|
+
* @param {number} [indent=2]
|
|
50111
|
+
* @returns {string} re-formatted HTML
|
|
50112
|
+
*/
|
|
50113
|
+
const reformatHTML = (html, indent = 2) => {
|
|
50114
|
+
// Remove leading/trailing newlines
|
|
50115
|
+
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
50116
|
+
// // Create a tab/indent with the specified number of spaces
|
|
50117
|
+
// const tab = ' '.repeat(indent);
|
|
50118
|
+
// // Indent each line of the HTML (converts to an array, indents each line, then joins back)
|
|
50119
|
+
// const indented = cleaned.split('\n').map((line: string) => `${tab}${line}`).join('\n');
|
|
50120
|
+
return cleaned;
|
|
50121
|
+
};
|
|
50122
|
+
|
|
50005
50123
|
;// CONCATENATED MODULE: ./processor/transform/images.ts
|
|
50006
50124
|
|
|
50007
50125
|
|
|
50008
|
-
|
|
50009
|
-
|
|
50010
|
-
|
|
50011
|
-
|
|
50012
|
-
|
|
50013
|
-
|
|
50014
|
-
|
|
50015
|
-
|
|
50016
|
-
|
|
50017
|
-
|
|
50018
|
-
|
|
50019
|
-
|
|
50020
|
-
|
|
50021
|
-
|
|
50022
|
-
|
|
50023
|
-
|
|
50024
|
-
|
|
50025
|
-
|
|
50026
|
-
|
|
50027
|
-
|
|
50028
|
-
|
|
50029
|
-
|
|
50126
|
+
|
|
50127
|
+
|
|
50128
|
+
const imageTransformer = () => (tree) => {
|
|
50129
|
+
visit(tree, 'paragraph', (node, i, parent) => {
|
|
50130
|
+
var _a;
|
|
50131
|
+
// check if inline
|
|
50132
|
+
if (parent.type !== 'root' ||
|
|
50133
|
+
((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 ||
|
|
50134
|
+
node.children[0].type !== 'image')
|
|
50135
|
+
return;
|
|
50136
|
+
const [{ alt, url, title }] = node.children;
|
|
50137
|
+
const newNode = {
|
|
50138
|
+
type: NodeTypes.imageBlock,
|
|
50139
|
+
alt,
|
|
50140
|
+
title,
|
|
50141
|
+
url,
|
|
50142
|
+
children: [],
|
|
50143
|
+
data: {
|
|
50144
|
+
hName: 'img',
|
|
50145
|
+
hProperties: Object.assign(Object.assign(Object.assign({}, (alt && { alt })), { src: url }), (title && { title })),
|
|
50146
|
+
},
|
|
50147
|
+
position: node.position,
|
|
50148
|
+
};
|
|
50149
|
+
parent.children.splice(i, 1, newNode);
|
|
50150
|
+
});
|
|
50151
|
+
const isImage = (node) => node.name === 'Image';
|
|
50152
|
+
visit(tree, isImage, (node) => {
|
|
50153
|
+
const attrs = getAttrs(node);
|
|
50154
|
+
if (attrs.caption) {
|
|
50155
|
+
node.children = lib_mdast(attrs.caption).children;
|
|
50156
|
+
}
|
|
50157
|
+
});
|
|
50158
|
+
return tree;
|
|
50030
50159
|
};
|
|
50031
50160
|
/* harmony default export */ const transform_images = (imageTransformer);
|
|
50032
50161
|
|
|
@@ -67016,6 +67145,7 @@ const gemojiTransformer = () => (tree) => {
|
|
|
67016
67145
|
|
|
67017
67146
|
;// CONCATENATED MODULE: ./processor/transform/inject-components.ts
|
|
67018
67147
|
|
|
67148
|
+
|
|
67019
67149
|
const inject = ({ components } = {}) => (node, index, parent) => {
|
|
67020
67150
|
if (!(node.name in components))
|
|
67021
67151
|
return;
|
|
@@ -67023,140 +67153,23 @@ const inject = ({ components } = {}) => (node, index, parent) => {
|
|
|
67023
67153
|
parent.children.splice(index, children.length, ...children);
|
|
67024
67154
|
};
|
|
67025
67155
|
const injectComponents = (opts) => () => tree => {
|
|
67026
|
-
visit(tree,
|
|
67027
|
-
visit(tree, 'mdxJsxTextElement', inject(opts));
|
|
67156
|
+
visit(tree, isMDXElement, inject(opts));
|
|
67028
67157
|
return tree;
|
|
67029
67158
|
};
|
|
67030
67159
|
/* harmony default export */ const inject_components = (injectComponents);
|
|
67031
67160
|
|
|
67032
|
-
;// CONCATENATED MODULE: ./processor/utils.ts
|
|
67033
|
-
/**
|
|
67034
|
-
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
67035
|
-
* This currently sets all the values to a string since we process/compile the MDX on the fly
|
|
67036
|
-
* through the editor, and it'll throw errors over malformed JSX. TODO: fix this.
|
|
67037
|
-
*
|
|
67038
|
-
* @template T
|
|
67039
|
-
* @param {Node} node
|
|
67040
|
-
* @returns {string} formatted hProperties as JSX attributes
|
|
67041
|
-
*/
|
|
67042
|
-
const formatHProps = (node) => {
|
|
67043
|
-
const hProps = getHProps(node);
|
|
67044
|
-
const hPropKeys = getHPropKeys(node);
|
|
67045
|
-
return hPropKeys.map(key => `${key}="${hProps[key]}"`).join(' ');
|
|
67046
|
-
};
|
|
67047
|
-
/**
|
|
67048
|
-
* Returns the hProperties of a node.
|
|
67049
|
-
*
|
|
67050
|
-
* @template T
|
|
67051
|
-
* @param {Node} node
|
|
67052
|
-
* @returns {T} hProperties
|
|
67053
|
-
*/
|
|
67054
|
-
const getHProps = (node) => {
|
|
67055
|
-
var _a;
|
|
67056
|
-
const hProps = ((_a = node.data) === null || _a === void 0 ? void 0 : _a.hProperties) || {};
|
|
67057
|
-
return hProps;
|
|
67058
|
-
};
|
|
67059
|
-
/**
|
|
67060
|
-
* Returns array of hProperty keys.
|
|
67061
|
-
*
|
|
67062
|
-
* @template T
|
|
67063
|
-
* @param {Node} node
|
|
67064
|
-
* @returns {Array} array of hProperty keys
|
|
67065
|
-
*/
|
|
67066
|
-
const getHPropKeys = (node) => {
|
|
67067
|
-
const hProps = getHProps(node);
|
|
67068
|
-
return Object.keys(hProps) || [];
|
|
67069
|
-
};
|
|
67070
|
-
/**
|
|
67071
|
-
* Gets the attributes of an MDX element and returns them as an object of hProperties.
|
|
67072
|
-
*
|
|
67073
|
-
* @template T
|
|
67074
|
-
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
67075
|
-
* @returns {T} object of hProperties
|
|
67076
|
-
*/
|
|
67077
|
-
const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
|
|
67078
|
-
if ('name' in attr) {
|
|
67079
|
-
memo[attr.name] = attr.value;
|
|
67080
|
-
}
|
|
67081
|
-
return memo;
|
|
67082
|
-
}, {});
|
|
67083
|
-
/**
|
|
67084
|
-
* Gets the children of an MDX element and returns them as an array of Text nodes.
|
|
67085
|
-
* Currently only being used by the HTML Block component, which only expects a single text node.
|
|
67086
|
-
*
|
|
67087
|
-
* @template T
|
|
67088
|
-
* @param {(MdxJsxFlowElement | MdxJsxTextElement)} jsx
|
|
67089
|
-
* @returns {Array} array of child text nodes
|
|
67090
|
-
*/
|
|
67091
|
-
const utils_getChildren = (jsx) => jsx.children.reduce((memo, child, i) => {
|
|
67092
|
-
memo[i] = {
|
|
67093
|
-
type: 'text',
|
|
67094
|
-
value: child.value,
|
|
67095
|
-
position: child.position,
|
|
67096
|
-
};
|
|
67097
|
-
return memo;
|
|
67098
|
-
}, []);
|
|
67099
|
-
/**
|
|
67100
|
-
* Tests if a node is an MDX element.
|
|
67101
|
-
* TODO: Make this more extensible to all types of nodes. isElement(node, 'type' or ['type1', 'type2']), say
|
|
67102
|
-
*
|
|
67103
|
-
* @param {Node} node
|
|
67104
|
-
* @returns {(node is MdxJsxFlowElement | MdxJsxTextElement)}
|
|
67105
|
-
*/
|
|
67106
|
-
const isMDXElement = (node) => {
|
|
67107
|
-
return ['mdxJsxFlowElement', 'mdxJsxTextElement'].includes(node.type);
|
|
67108
|
-
};
|
|
67109
|
-
/**
|
|
67110
|
-
* Takes an HTML string and formats it for display in the editor. Removes leading/trailing newlines
|
|
67111
|
-
* and unindents the HTML.
|
|
67112
|
-
*
|
|
67113
|
-
* @param {string} html
|
|
67114
|
-
* @returns {string} formatted HTML
|
|
67115
|
-
*/
|
|
67116
|
-
const formatHTML = (html) => {
|
|
67117
|
-
// Remove leading/trailing backticks if present, since they're used to keep the HTML
|
|
67118
|
-
// from being parsed prematurely
|
|
67119
|
-
if (html.startsWith('`') && html.endsWith('`')) {
|
|
67120
|
-
html = html.slice(1, -1);
|
|
67121
|
-
}
|
|
67122
|
-
// Removes the leading/trailing newlines
|
|
67123
|
-
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
67124
|
-
// // Get the number of spaces in the first line to determine the tab size
|
|
67125
|
-
// const tab = cleaned.match(/^\s*/)[0].length;
|
|
67126
|
-
// // Remove the first indentation level from each line
|
|
67127
|
-
// const tabRegex = new RegExp(`^\\s{${tab}}`, 'gm');
|
|
67128
|
-
// const unindented = cleaned.replace(tabRegex, '');
|
|
67129
|
-
return cleaned;
|
|
67130
|
-
};
|
|
67131
|
-
/**
|
|
67132
|
-
* Reformat HTML for the markdown/mdx by adding an indentation to each line. This assures that the
|
|
67133
|
-
* HTML is indentend properly within the HTMLBlock component when rendered in the markdown/mdx.
|
|
67134
|
-
*
|
|
67135
|
-
* @param {string} html
|
|
67136
|
-
* @param {number} [indent=2]
|
|
67137
|
-
* @returns {string} re-formatted HTML
|
|
67138
|
-
*/
|
|
67139
|
-
const reformatHTML = (html, indent = 2) => {
|
|
67140
|
-
// Remove leading/trailing newlines
|
|
67141
|
-
const cleaned = html.replace(/^\s*\n|\n\s*$/g, '');
|
|
67142
|
-
// // Create a tab/indent with the specified number of spaces
|
|
67143
|
-
// const tab = ' '.repeat(indent);
|
|
67144
|
-
// // Indent each line of the HTML (converts to an array, indents each line, then joins back)
|
|
67145
|
-
// const indented = cleaned.split('\n').map((line: string) => `${tab}${line}`).join('\n');
|
|
67146
|
-
return cleaned;
|
|
67147
|
-
};
|
|
67148
|
-
|
|
67149
67161
|
;// CONCATENATED MODULE: ./processor/transform/readme-components.ts
|
|
67150
67162
|
|
|
67151
67163
|
|
|
67152
67164
|
|
|
67165
|
+
|
|
67153
67166
|
const readme_components_types = {
|
|
67154
67167
|
Callout: NodeTypes['callout'],
|
|
67155
67168
|
Code: 'code',
|
|
67156
67169
|
CodeTabs: NodeTypes['codeTabs'],
|
|
67157
67170
|
EmbedBlock: NodeTypes['embed-block'],
|
|
67158
67171
|
Glossary: NodeTypes['glossary'],
|
|
67159
|
-
ImageBlock: NodeTypes
|
|
67172
|
+
ImageBlock: NodeTypes.imageBlock,
|
|
67160
67173
|
HTMLBlock: NodeTypes.htmlBlock,
|
|
67161
67174
|
Table: 'table',
|
|
67162
67175
|
Variable: NodeTypes['variable'],
|
|
@@ -67189,6 +67202,7 @@ const coerceJsxToMd = ({ components = {} } = {}) => (node, index, parent) => {
|
|
|
67189
67202
|
const mdNode = {
|
|
67190
67203
|
alt,
|
|
67191
67204
|
position,
|
|
67205
|
+
children: attrs.caption ? lib_mdast(attrs.caption).children : node.children,
|
|
67192
67206
|
title,
|
|
67193
67207
|
type: NodeTypes.imageBlock,
|
|
67194
67208
|
url: url || attrs.src,
|
|
@@ -67304,26 +67318,39 @@ const readmeToMdx = () => tree => {
|
|
|
67304
67318
|
|
|
67305
67319
|
;// CONCATENATED MODULE: ./processor/transform/variables.ts
|
|
67306
67320
|
|
|
67307
|
-
|
|
67321
|
+
|
|
67322
|
+
const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
67308
67323
|
visit(tree, (node, index, parent) => {
|
|
67309
67324
|
if (!['mdxFlowExpression', 'mdxTextExpression'].includes(node.type) || !('value' in node))
|
|
67310
67325
|
return;
|
|
67311
67326
|
const match = node.value.match(/^user\.(?<value>.*)$/);
|
|
67312
67327
|
if (!match)
|
|
67313
67328
|
return;
|
|
67314
|
-
let variable =
|
|
67315
|
-
|
|
67316
|
-
|
|
67317
|
-
|
|
67318
|
-
|
|
67319
|
-
|
|
67320
|
-
|
|
67321
|
-
|
|
67329
|
+
let variable = asMdx
|
|
67330
|
+
? {
|
|
67331
|
+
type: 'mdxJsxTextElement',
|
|
67332
|
+
name: 'Variable',
|
|
67333
|
+
attributes: [
|
|
67334
|
+
{
|
|
67335
|
+
type: 'mdxJsxAttribute',
|
|
67336
|
+
name: 'name',
|
|
67337
|
+
value: match.groups.value,
|
|
67338
|
+
},
|
|
67339
|
+
],
|
|
67340
|
+
children: [],
|
|
67341
|
+
position: node.position,
|
|
67342
|
+
}
|
|
67343
|
+
: {
|
|
67344
|
+
type: NodeTypes.variable,
|
|
67345
|
+
data: {
|
|
67346
|
+
hName: 'Variable',
|
|
67347
|
+
hProperties: {
|
|
67348
|
+
name: match.groups.value,
|
|
67349
|
+
},
|
|
67322
67350
|
},
|
|
67323
|
-
|
|
67324
|
-
|
|
67325
|
-
|
|
67326
|
-
};
|
|
67351
|
+
value: `{${node.value}}`,
|
|
67352
|
+
position: node.position,
|
|
67353
|
+
};
|
|
67327
67354
|
parent.children.splice(index, 1, variable);
|
|
67328
67355
|
});
|
|
67329
67356
|
return tree;
|
|
@@ -67341,14 +67368,7 @@ const variables = () => tree => {
|
|
|
67341
67368
|
|
|
67342
67369
|
|
|
67343
67370
|
|
|
67344
|
-
/* harmony default export */ const transform = ([
|
|
67345
|
-
callouts,
|
|
67346
|
-
code_tabs,
|
|
67347
|
-
transform_embeds,
|
|
67348
|
-
transform_images,
|
|
67349
|
-
gemoji_,
|
|
67350
|
-
transform_variables,
|
|
67351
|
-
]);
|
|
67371
|
+
/* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, transform_images, gemoji_]);
|
|
67352
67372
|
|
|
67353
67373
|
;// CONCATENATED MODULE: ./lib/ast-processor.ts
|
|
67354
67374
|
|
|
@@ -67360,6 +67380,7 @@ const remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform];
|
|
|
67360
67380
|
const astProcessor = (opts = { components: {} }) => remark()
|
|
67361
67381
|
.use(remarkMdx)
|
|
67362
67382
|
.use(remarkPlugins)
|
|
67383
|
+
.use(transform_variables, { asMdx: false })
|
|
67363
67384
|
.use(readme_components({ components: opts.components }));
|
|
67364
67385
|
/* harmony default export */ const ast_processor = (astProcessor);
|
|
67365
67386
|
|
|
@@ -80000,7 +80021,7 @@ var compile_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
80000
80021
|
|
|
80001
80022
|
|
|
80002
80023
|
|
|
80003
|
-
const compile_remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform];
|
|
80024
|
+
const compile_remarkPlugins = [remarkFrontmatter, remarkGfm, ...transform, transform_variables];
|
|
80004
80025
|
const compile_compile = (text, _a = {}) => {
|
|
80005
80026
|
var { components } = _a, opts = compile_rest(_a, ["components"]);
|
|
80006
80027
|
try {
|
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.64",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|