@readme/markdown 7.5.0 → 7.5.1
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/dist/main.js +23 -31
- package/dist/main.node.js +23 -31
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -47933,6 +47933,9 @@ const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
|
|
|
47933
47933
|
if (typeof attr.value === 'string') {
|
|
47934
47934
|
memo[attr.name] = attr.value;
|
|
47935
47935
|
}
|
|
47936
|
+
else if (attr.value === null) {
|
|
47937
|
+
memo[attr.name] = true;
|
|
47938
|
+
}
|
|
47936
47939
|
else if (attr.value.value !== 'undefined') {
|
|
47937
47940
|
memo[attr.name] = JSON.parse(attr.value.value);
|
|
47938
47941
|
}
|
|
@@ -48007,15 +48010,15 @@ const reformatHTML = (html, indent = 2) => {
|
|
|
48007
48010
|
const toAttributes = (object, keys = []) => {
|
|
48008
48011
|
let attributes = [];
|
|
48009
48012
|
Object.entries(object).forEach(([name, v]) => {
|
|
48010
|
-
if (
|
|
48013
|
+
if (keys.length > 0 && !keys.includes(name))
|
|
48011
48014
|
return;
|
|
48012
48015
|
let value;
|
|
48013
|
-
if (typeof v === '
|
|
48014
|
-
value = v;
|
|
48015
|
-
}
|
|
48016
|
-
else if (typeof v === 'undefined') {
|
|
48016
|
+
if (typeof v === 'undefined' || v === null || v === '') {
|
|
48017
48017
|
return;
|
|
48018
48018
|
}
|
|
48019
|
+
else if (typeof v === 'string') {
|
|
48020
|
+
value = v;
|
|
48021
|
+
}
|
|
48019
48022
|
else {
|
|
48020
48023
|
/* values can be null, undefined, string, or a expression, eg:
|
|
48021
48024
|
*
|
|
@@ -48057,18 +48060,21 @@ const imageTransformer = () => (tree) => {
|
|
|
48057
48060
|
if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
|
|
48058
48061
|
return;
|
|
48059
48062
|
const [{ alt, url, title }] = node.children;
|
|
48060
|
-
const
|
|
48061
|
-
type: NodeTypes.imageBlock,
|
|
48063
|
+
const attrs = {
|
|
48062
48064
|
alt,
|
|
48063
48065
|
title,
|
|
48064
|
-
url,
|
|
48065
48066
|
children: [],
|
|
48067
|
+
src: url,
|
|
48068
|
+
};
|
|
48069
|
+
const newNode = Object.assign(Object.assign({ type: NodeTypes.imageBlock }, attrs), {
|
|
48070
|
+
/*
|
|
48071
|
+
* @note: Using data.hName here means that we don't have to transform
|
|
48072
|
+
* this to an MdxJsxFlowElement, and rehype will transform it correctly
|
|
48073
|
+
*/
|
|
48066
48074
|
data: {
|
|
48067
48075
|
hName: 'img',
|
|
48068
|
-
hProperties:
|
|
48069
|
-
},
|
|
48070
|
-
position: node.position,
|
|
48071
|
-
};
|
|
48076
|
+
hProperties: attrs,
|
|
48077
|
+
}, position: node.position });
|
|
48072
48078
|
parent.children.splice(i, 1, newNode);
|
|
48073
48079
|
});
|
|
48074
48080
|
const isImage = (node) => node.name === 'Image';
|
|
@@ -65163,20 +65169,12 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
65163
65169
|
}
|
|
65164
65170
|
else if (node.name === 'Image') {
|
|
65165
65171
|
const { position } = node;
|
|
65166
|
-
const { alt = '',
|
|
65167
|
-
const attrs =
|
|
65168
|
-
const mdNode = {
|
|
65169
|
-
alt,
|
|
65170
|
-
position,
|
|
65171
|
-
children: attrs.caption ? lib_mdast(attrs.caption).children : node.children,
|
|
65172
|
-
title,
|
|
65173
|
-
type: NodeTypes.imageBlock,
|
|
65174
|
-
url: url || attrs.src,
|
|
65175
|
-
data: {
|
|
65172
|
+
const { alt = '', align, border, caption, title = null, width, src, } = getAttrs(node);
|
|
65173
|
+
const attrs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (align && { align })), (border && { border })), (src && { src })), (width && { width })), { alt, children: caption ? lib_mdast(caption).children : node.children, title });
|
|
65174
|
+
const mdNode = Object.assign(Object.assign({}, attrs), { position, type: NodeTypes.imageBlock, data: {
|
|
65176
65175
|
hName: 'img',
|
|
65177
65176
|
hProperties: attrs,
|
|
65178
|
-
}
|
|
65179
|
-
};
|
|
65177
|
+
} });
|
|
65180
65178
|
parent.children[index] = mdNode;
|
|
65181
65179
|
}
|
|
65182
65180
|
else if (node.name === 'HTMLBlock') {
|
|
@@ -65330,13 +65328,7 @@ const readmeToMdx = () => tree => {
|
|
|
65330
65328
|
});
|
|
65331
65329
|
}
|
|
65332
65330
|
else {
|
|
65333
|
-
parent.children.splice(index, 1, {
|
|
65334
|
-
type: 'image',
|
|
65335
|
-
children: [],
|
|
65336
|
-
url: image.url,
|
|
65337
|
-
title: image.title,
|
|
65338
|
-
alt: image.alt,
|
|
65339
|
-
});
|
|
65331
|
+
parent.children.splice(index, 1, Object.assign(Object.assign(Object.assign({ type: 'image', children: [] }, (image.src && { url: image.src })), (image.title && { title: image.title })), (image.alt && { alt: image.alt })));
|
|
65340
65332
|
}
|
|
65341
65333
|
});
|
|
65342
65334
|
visit(tree, 'html', (node, index, parent) => {
|
package/dist/main.node.js
CHANGED
|
@@ -48920,6 +48920,9 @@ const getAttrs = (jsx) => jsx.attributes.reduce((memo, attr) => {
|
|
|
48920
48920
|
if (typeof attr.value === 'string') {
|
|
48921
48921
|
memo[attr.name] = attr.value;
|
|
48922
48922
|
}
|
|
48923
|
+
else if (attr.value === null) {
|
|
48924
|
+
memo[attr.name] = true;
|
|
48925
|
+
}
|
|
48923
48926
|
else if (attr.value.value !== 'undefined') {
|
|
48924
48927
|
memo[attr.name] = JSON.parse(attr.value.value);
|
|
48925
48928
|
}
|
|
@@ -48994,15 +48997,15 @@ const reformatHTML = (html, indent = 2) => {
|
|
|
48994
48997
|
const toAttributes = (object, keys = []) => {
|
|
48995
48998
|
let attributes = [];
|
|
48996
48999
|
Object.entries(object).forEach(([name, v]) => {
|
|
48997
|
-
if (
|
|
49000
|
+
if (keys.length > 0 && !keys.includes(name))
|
|
48998
49001
|
return;
|
|
48999
49002
|
let value;
|
|
49000
|
-
if (typeof v === '
|
|
49001
|
-
value = v;
|
|
49002
|
-
}
|
|
49003
|
-
else if (typeof v === 'undefined') {
|
|
49003
|
+
if (typeof v === 'undefined' || v === null || v === '') {
|
|
49004
49004
|
return;
|
|
49005
49005
|
}
|
|
49006
|
+
else if (typeof v === 'string') {
|
|
49007
|
+
value = v;
|
|
49008
|
+
}
|
|
49006
49009
|
else {
|
|
49007
49010
|
/* values can be null, undefined, string, or a expression, eg:
|
|
49008
49011
|
*
|
|
@@ -49044,18 +49047,21 @@ const imageTransformer = () => (tree) => {
|
|
|
49044
49047
|
if (parent.type !== 'root' || ((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 1 || node.children[0].type !== 'image')
|
|
49045
49048
|
return;
|
|
49046
49049
|
const [{ alt, url, title }] = node.children;
|
|
49047
|
-
const
|
|
49048
|
-
type: NodeTypes.imageBlock,
|
|
49050
|
+
const attrs = {
|
|
49049
49051
|
alt,
|
|
49050
49052
|
title,
|
|
49051
|
-
url,
|
|
49052
49053
|
children: [],
|
|
49054
|
+
src: url,
|
|
49055
|
+
};
|
|
49056
|
+
const newNode = Object.assign(Object.assign({ type: NodeTypes.imageBlock }, attrs), {
|
|
49057
|
+
/*
|
|
49058
|
+
* @note: Using data.hName here means that we don't have to transform
|
|
49059
|
+
* this to an MdxJsxFlowElement, and rehype will transform it correctly
|
|
49060
|
+
*/
|
|
49053
49061
|
data: {
|
|
49054
49062
|
hName: 'img',
|
|
49055
|
-
hProperties:
|
|
49056
|
-
},
|
|
49057
|
-
position: node.position,
|
|
49058
|
-
};
|
|
49063
|
+
hProperties: attrs,
|
|
49064
|
+
}, position: node.position });
|
|
49059
49065
|
parent.children.splice(i, 1, newNode);
|
|
49060
49066
|
});
|
|
49061
49067
|
const isImage = (node) => node.name === 'Image';
|
|
@@ -66150,20 +66156,12 @@ const coerceJsxToMd = ({ components = {}, html = false } = {}) => (node, index,
|
|
|
66150
66156
|
}
|
|
66151
66157
|
else if (node.name === 'Image') {
|
|
66152
66158
|
const { position } = node;
|
|
66153
|
-
const { alt = '',
|
|
66154
|
-
const attrs =
|
|
66155
|
-
const mdNode = {
|
|
66156
|
-
alt,
|
|
66157
|
-
position,
|
|
66158
|
-
children: attrs.caption ? lib_mdast(attrs.caption).children : node.children,
|
|
66159
|
-
title,
|
|
66160
|
-
type: NodeTypes.imageBlock,
|
|
66161
|
-
url: url || attrs.src,
|
|
66162
|
-
data: {
|
|
66159
|
+
const { alt = '', align, border, caption, title = null, width, src, } = getAttrs(node);
|
|
66160
|
+
const attrs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (align && { align })), (border && { border })), (src && { src })), (width && { width })), { alt, children: caption ? lib_mdast(caption).children : node.children, title });
|
|
66161
|
+
const mdNode = Object.assign(Object.assign({}, attrs), { position, type: NodeTypes.imageBlock, data: {
|
|
66163
66162
|
hName: 'img',
|
|
66164
66163
|
hProperties: attrs,
|
|
66165
|
-
}
|
|
66166
|
-
};
|
|
66164
|
+
} });
|
|
66167
66165
|
parent.children[index] = mdNode;
|
|
66168
66166
|
}
|
|
66169
66167
|
else if (node.name === 'HTMLBlock') {
|
|
@@ -66317,13 +66315,7 @@ const readmeToMdx = () => tree => {
|
|
|
66317
66315
|
});
|
|
66318
66316
|
}
|
|
66319
66317
|
else {
|
|
66320
|
-
parent.children.splice(index, 1, {
|
|
66321
|
-
type: 'image',
|
|
66322
|
-
children: [],
|
|
66323
|
-
url: image.url,
|
|
66324
|
-
title: image.title,
|
|
66325
|
-
alt: image.alt,
|
|
66326
|
-
});
|
|
66318
|
+
parent.children.splice(index, 1, Object.assign(Object.assign(Object.assign({ type: 'image', children: [] }, (image.src && { url: image.src })), (image.title && { title: image.title })), (image.alt && { alt: image.alt })));
|
|
66327
66319
|
}
|
|
66328
66320
|
});
|
|
66329
66321
|
visit(tree, 'html', (node, index, parent) => {
|
package/package.json
CHANGED