@readme/markdown 6.75.0-beta.69 → 6.75.0-beta.71
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 +133 -0
- package/dist/main.node.js +133 -0
- package/dist/processor/compile/compatibility.d.ts +10 -0
- package/dist/processor/transform/div.d.ts +3 -0
- package/dist/processor/transform/index.d.ts +3 -1
- package/dist/processor/transform/tables-to-jsx.d.ts +3 -0
- package/package.json +2 -1
package/dist/main.js
CHANGED
|
@@ -65698,6 +65698,39 @@ const gemojiTransformer = () => (tree) => {
|
|
|
65698
65698
|
};
|
|
65699
65699
|
/* harmony default export */ const gemoji_ = (gemojiTransformer);
|
|
65700
65700
|
|
|
65701
|
+
;// CONCATENATED MODULE: ./processor/transform/div.ts
|
|
65702
|
+
var div_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
65703
|
+
var t = {};
|
|
65704
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
65705
|
+
t[p] = s[p];
|
|
65706
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
65707
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
65708
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
65709
|
+
t[p[i]] = s[p[i]];
|
|
65710
|
+
}
|
|
65711
|
+
return t;
|
|
65712
|
+
};
|
|
65713
|
+
|
|
65714
|
+
|
|
65715
|
+
const divTransformer = () => tree => {
|
|
65716
|
+
visit(tree, 'div', (node, index, parent) => {
|
|
65717
|
+
var _a;
|
|
65718
|
+
const type = (_a = node.data) === null || _a === void 0 ? void 0 : _a.hName;
|
|
65719
|
+
switch (type) {
|
|
65720
|
+
// Check if the div is a tutorial-tile in disguise
|
|
65721
|
+
case NodeTypes.tutorialTile:
|
|
65722
|
+
const _b = node.data, { hName, hProperties } = _b, rest = div_rest(_b, ["hName", "hProperties"]);
|
|
65723
|
+
const tile = Object.assign(Object.assign({}, rest), { type: NodeTypes.tutorialTile });
|
|
65724
|
+
parent.children.splice(index, 1, tile);
|
|
65725
|
+
// idk what this is and/or just make it a paragraph
|
|
65726
|
+
default:
|
|
65727
|
+
node.type = type || 'paragraph';
|
|
65728
|
+
}
|
|
65729
|
+
});
|
|
65730
|
+
return tree;
|
|
65731
|
+
};
|
|
65732
|
+
/* harmony default export */ const div = (divTransformer);
|
|
65733
|
+
|
|
65701
65734
|
;// CONCATENATED MODULE: ./processor/transform/inject-components.ts
|
|
65702
65735
|
|
|
65703
65736
|
|
|
@@ -65850,6 +65883,11 @@ const readmeComponents = (opts) => () => tree => {
|
|
|
65850
65883
|
|
|
65851
65884
|
|
|
65852
65885
|
const readmeToMdx = () => tree => {
|
|
65886
|
+
// Unwrap pinned nodes, replace rdme-pin with its child node
|
|
65887
|
+
visit(tree, 'rdme-pin', (node, i, parent) => {
|
|
65888
|
+
const newNode = node.children[0];
|
|
65889
|
+
parent.children.splice(i, 1, newNode);
|
|
65890
|
+
});
|
|
65853
65891
|
visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
|
|
65854
65892
|
const attributes = ['backgroundColor', 'emoji', 'id', 'link', 'slug', 'title'].map(name => {
|
|
65855
65893
|
const value = tile[name];
|
|
@@ -65912,6 +65950,91 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
65912
65950
|
};
|
|
65913
65951
|
/* harmony default export */ const transform_variables = (variables);
|
|
65914
65952
|
|
|
65953
|
+
;// CONCATENATED MODULE: ./processor/transform/tables-to-jsx.ts
|
|
65954
|
+
|
|
65955
|
+
|
|
65956
|
+
|
|
65957
|
+
|
|
65958
|
+
|
|
65959
|
+
const visitor = (table, index, parent) => {
|
|
65960
|
+
let hasFlowContent = false;
|
|
65961
|
+
const tableCellVisitor = (cell) => {
|
|
65962
|
+
if (!phrasing(cell.children[0])) {
|
|
65963
|
+
hasFlowContent = true;
|
|
65964
|
+
return EXIT;
|
|
65965
|
+
}
|
|
65966
|
+
visit(cell, 'text', (text) => {
|
|
65967
|
+
if (text.value.match(/\n/)) {
|
|
65968
|
+
hasFlowContent = true;
|
|
65969
|
+
return EXIT;
|
|
65970
|
+
}
|
|
65971
|
+
});
|
|
65972
|
+
};
|
|
65973
|
+
visit(table, 'tableCell', tableCellVisitor);
|
|
65974
|
+
if (!hasFlowContent)
|
|
65975
|
+
return;
|
|
65976
|
+
const head = {
|
|
65977
|
+
type: 'mdxJsxFlowElement',
|
|
65978
|
+
name: 'thead',
|
|
65979
|
+
children: [
|
|
65980
|
+
{
|
|
65981
|
+
type: 'mdxJsxFlowElement',
|
|
65982
|
+
name: 'tr',
|
|
65983
|
+
children: table.children[0].children.map((cell, idx) => {
|
|
65984
|
+
const proxy = fromMarkdown(`<div style={{ align: "${table.align[idx]}" }}></div>`, {
|
|
65985
|
+
extensions: [mdxJsx()],
|
|
65986
|
+
mdastExtensions: [mdxJsxFromMarkdown()],
|
|
65987
|
+
});
|
|
65988
|
+
// @ts-ignore
|
|
65989
|
+
const { attributes } = proxy.children[0];
|
|
65990
|
+
return {
|
|
65991
|
+
type: 'mdxJsxFlowElement',
|
|
65992
|
+
name: 'th',
|
|
65993
|
+
attributes,
|
|
65994
|
+
children: cell.children,
|
|
65995
|
+
};
|
|
65996
|
+
}),
|
|
65997
|
+
},
|
|
65998
|
+
],
|
|
65999
|
+
};
|
|
66000
|
+
const body = {
|
|
66001
|
+
type: 'mdxJsxFlowElement',
|
|
66002
|
+
name: 'tbody',
|
|
66003
|
+
children: table.children.splice(1).map(row => {
|
|
66004
|
+
return {
|
|
66005
|
+
type: 'mdxJsxFlowElement',
|
|
66006
|
+
name: 'tr',
|
|
66007
|
+
children: row.children.map((cell, idx) => {
|
|
66008
|
+
const proxy = fromMarkdown(`<div style={{ align: "${table.align[idx]}" }}></div>`, {
|
|
66009
|
+
extensions: [mdxJsx()],
|
|
66010
|
+
mdastExtensions: [mdxJsxFromMarkdown()],
|
|
66011
|
+
});
|
|
66012
|
+
// @ts-ignore
|
|
66013
|
+
const { attributes } = proxy.children[0];
|
|
66014
|
+
return {
|
|
66015
|
+
type: 'mdxJsxFlowElement',
|
|
66016
|
+
name: 'th',
|
|
66017
|
+
attributes,
|
|
66018
|
+
children: cell.children,
|
|
66019
|
+
};
|
|
66020
|
+
}),
|
|
66021
|
+
};
|
|
66022
|
+
}),
|
|
66023
|
+
};
|
|
66024
|
+
const jsx = {
|
|
66025
|
+
type: 'mdxJsxFlowElement',
|
|
66026
|
+
name: 'Table',
|
|
66027
|
+
children: [head, body],
|
|
66028
|
+
};
|
|
66029
|
+
// @ts-ignore
|
|
66030
|
+
parent.children[index] = jsx;
|
|
66031
|
+
};
|
|
66032
|
+
const tablesToJsx = () => tree => {
|
|
66033
|
+
visit(tree, 'table', visitor);
|
|
66034
|
+
return tree;
|
|
66035
|
+
};
|
|
66036
|
+
/* harmony default export */ const tables_to_jsx = (tablesToJsx);
|
|
66037
|
+
|
|
65915
66038
|
;// CONCATENATED MODULE: ./processor/transform/index.ts
|
|
65916
66039
|
|
|
65917
66040
|
|
|
@@ -65923,6 +66046,8 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
65923
66046
|
|
|
65924
66047
|
|
|
65925
66048
|
|
|
66049
|
+
|
|
66050
|
+
|
|
65926
66051
|
/* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, transform_images, gemoji_]);
|
|
65927
66052
|
|
|
65928
66053
|
;// CONCATENATED MODULE: ./node_modules/rehype-slug/node_modules/github-slugger/regex.js
|
|
@@ -94467,6 +94592,10 @@ const compatibility = (node) => {
|
|
|
94467
94592
|
return figureToImageBlock(node);
|
|
94468
94593
|
case 'embed':
|
|
94469
94594
|
return embedToEmbedBlock(node);
|
|
94595
|
+
case 'i':
|
|
94596
|
+
return `:${node.data.hProperties.className[1]}:`;
|
|
94597
|
+
case 'yaml':
|
|
94598
|
+
return `---\n${node.value}\n---`;
|
|
94470
94599
|
default:
|
|
94471
94600
|
throw new Error('Unhandled node type!');
|
|
94472
94601
|
}
|
|
@@ -94504,6 +94633,8 @@ function compilers() {
|
|
|
94504
94633
|
escape: compile_compatibility,
|
|
94505
94634
|
figure: compile_compatibility,
|
|
94506
94635
|
html: compile_compatibility,
|
|
94636
|
+
i: compile_compatibility,
|
|
94637
|
+
yaml: compile_compatibility,
|
|
94507
94638
|
};
|
|
94508
94639
|
toMarkdownExtensions.push({ extensions: [{ handlers }] });
|
|
94509
94640
|
}
|
|
@@ -94522,7 +94653,9 @@ const mdx_mdx = (tree, { hast = false } = {}) => {
|
|
|
94522
94653
|
.use(hast ? rehypeRemark : undefined)
|
|
94523
94654
|
.use(remarkMdx)
|
|
94524
94655
|
.use(remarkGfm)
|
|
94656
|
+
.use(div)
|
|
94525
94657
|
.use(readme_to_mdx)
|
|
94658
|
+
.use(tables_to_jsx)
|
|
94526
94659
|
.use(remarkStringify)
|
|
94527
94660
|
.use(processor_compile);
|
|
94528
94661
|
return processor.stringify(processor.runSync(tree));
|
package/dist/main.node.js
CHANGED
|
@@ -67151,6 +67151,39 @@ const gemojiTransformer = () => (tree) => {
|
|
|
67151
67151
|
};
|
|
67152
67152
|
/* harmony default export */ const gemoji_ = (gemojiTransformer);
|
|
67153
67153
|
|
|
67154
|
+
;// CONCATENATED MODULE: ./processor/transform/div.ts
|
|
67155
|
+
var div_rest = (undefined && undefined.__rest) || function (s, e) {
|
|
67156
|
+
var t = {};
|
|
67157
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67158
|
+
t[p] = s[p];
|
|
67159
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
67160
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
67161
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
67162
|
+
t[p[i]] = s[p[i]];
|
|
67163
|
+
}
|
|
67164
|
+
return t;
|
|
67165
|
+
};
|
|
67166
|
+
|
|
67167
|
+
|
|
67168
|
+
const divTransformer = () => tree => {
|
|
67169
|
+
visit(tree, 'div', (node, index, parent) => {
|
|
67170
|
+
var _a;
|
|
67171
|
+
const type = (_a = node.data) === null || _a === void 0 ? void 0 : _a.hName;
|
|
67172
|
+
switch (type) {
|
|
67173
|
+
// Check if the div is a tutorial-tile in disguise
|
|
67174
|
+
case NodeTypes.tutorialTile:
|
|
67175
|
+
const _b = node.data, { hName, hProperties } = _b, rest = div_rest(_b, ["hName", "hProperties"]);
|
|
67176
|
+
const tile = Object.assign(Object.assign({}, rest), { type: NodeTypes.tutorialTile });
|
|
67177
|
+
parent.children.splice(index, 1, tile);
|
|
67178
|
+
// idk what this is and/or just make it a paragraph
|
|
67179
|
+
default:
|
|
67180
|
+
node.type = type || 'paragraph';
|
|
67181
|
+
}
|
|
67182
|
+
});
|
|
67183
|
+
return tree;
|
|
67184
|
+
};
|
|
67185
|
+
/* harmony default export */ const transform_div = (divTransformer);
|
|
67186
|
+
|
|
67154
67187
|
;// CONCATENATED MODULE: ./processor/transform/inject-components.ts
|
|
67155
67188
|
|
|
67156
67189
|
|
|
@@ -67303,6 +67336,11 @@ const readmeComponents = (opts) => () => tree => {
|
|
|
67303
67336
|
|
|
67304
67337
|
|
|
67305
67338
|
const readmeToMdx = () => tree => {
|
|
67339
|
+
// Unwrap pinned nodes, replace rdme-pin with its child node
|
|
67340
|
+
visit(tree, 'rdme-pin', (node, i, parent) => {
|
|
67341
|
+
const newNode = node.children[0];
|
|
67342
|
+
parent.children.splice(i, 1, newNode);
|
|
67343
|
+
});
|
|
67306
67344
|
visit(tree, NodeTypes.tutorialTile, (tile, index, parent) => {
|
|
67307
67345
|
const attributes = ['backgroundColor', 'emoji', 'id', 'link', 'slug', 'title'].map(name => {
|
|
67308
67346
|
const value = tile[name];
|
|
@@ -67365,6 +67403,91 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
67365
67403
|
};
|
|
67366
67404
|
/* harmony default export */ const transform_variables = (variables);
|
|
67367
67405
|
|
|
67406
|
+
;// CONCATENATED MODULE: ./processor/transform/tables-to-jsx.ts
|
|
67407
|
+
|
|
67408
|
+
|
|
67409
|
+
|
|
67410
|
+
|
|
67411
|
+
|
|
67412
|
+
const visitor = (table, index, parent) => {
|
|
67413
|
+
let hasFlowContent = false;
|
|
67414
|
+
const tableCellVisitor = (cell) => {
|
|
67415
|
+
if (!phrasing(cell.children[0])) {
|
|
67416
|
+
hasFlowContent = true;
|
|
67417
|
+
return EXIT;
|
|
67418
|
+
}
|
|
67419
|
+
visit(cell, 'text', (text) => {
|
|
67420
|
+
if (text.value.match(/\n/)) {
|
|
67421
|
+
hasFlowContent = true;
|
|
67422
|
+
return EXIT;
|
|
67423
|
+
}
|
|
67424
|
+
});
|
|
67425
|
+
};
|
|
67426
|
+
visit(table, 'tableCell', tableCellVisitor);
|
|
67427
|
+
if (!hasFlowContent)
|
|
67428
|
+
return;
|
|
67429
|
+
const head = {
|
|
67430
|
+
type: 'mdxJsxFlowElement',
|
|
67431
|
+
name: 'thead',
|
|
67432
|
+
children: [
|
|
67433
|
+
{
|
|
67434
|
+
type: 'mdxJsxFlowElement',
|
|
67435
|
+
name: 'tr',
|
|
67436
|
+
children: table.children[0].children.map((cell, idx) => {
|
|
67437
|
+
const proxy = fromMarkdown(`<div style={{ align: "${table.align[idx]}" }}></div>`, {
|
|
67438
|
+
extensions: [mdxJsx()],
|
|
67439
|
+
mdastExtensions: [mdxJsxFromMarkdown()],
|
|
67440
|
+
});
|
|
67441
|
+
// @ts-ignore
|
|
67442
|
+
const { attributes } = proxy.children[0];
|
|
67443
|
+
return {
|
|
67444
|
+
type: 'mdxJsxFlowElement',
|
|
67445
|
+
name: 'th',
|
|
67446
|
+
attributes,
|
|
67447
|
+
children: cell.children,
|
|
67448
|
+
};
|
|
67449
|
+
}),
|
|
67450
|
+
},
|
|
67451
|
+
],
|
|
67452
|
+
};
|
|
67453
|
+
const body = {
|
|
67454
|
+
type: 'mdxJsxFlowElement',
|
|
67455
|
+
name: 'tbody',
|
|
67456
|
+
children: table.children.splice(1).map(row => {
|
|
67457
|
+
return {
|
|
67458
|
+
type: 'mdxJsxFlowElement',
|
|
67459
|
+
name: 'tr',
|
|
67460
|
+
children: row.children.map((cell, idx) => {
|
|
67461
|
+
const proxy = fromMarkdown(`<div style={{ align: "${table.align[idx]}" }}></div>`, {
|
|
67462
|
+
extensions: [mdxJsx()],
|
|
67463
|
+
mdastExtensions: [mdxJsxFromMarkdown()],
|
|
67464
|
+
});
|
|
67465
|
+
// @ts-ignore
|
|
67466
|
+
const { attributes } = proxy.children[0];
|
|
67467
|
+
return {
|
|
67468
|
+
type: 'mdxJsxFlowElement',
|
|
67469
|
+
name: 'th',
|
|
67470
|
+
attributes,
|
|
67471
|
+
children: cell.children,
|
|
67472
|
+
};
|
|
67473
|
+
}),
|
|
67474
|
+
};
|
|
67475
|
+
}),
|
|
67476
|
+
};
|
|
67477
|
+
const jsx = {
|
|
67478
|
+
type: 'mdxJsxFlowElement',
|
|
67479
|
+
name: 'Table',
|
|
67480
|
+
children: [head, body],
|
|
67481
|
+
};
|
|
67482
|
+
// @ts-ignore
|
|
67483
|
+
parent.children[index] = jsx;
|
|
67484
|
+
};
|
|
67485
|
+
const tablesToJsx = () => tree => {
|
|
67486
|
+
visit(tree, 'table', visitor);
|
|
67487
|
+
return tree;
|
|
67488
|
+
};
|
|
67489
|
+
/* harmony default export */ const tables_to_jsx = (tablesToJsx);
|
|
67490
|
+
|
|
67368
67491
|
;// CONCATENATED MODULE: ./processor/transform/index.ts
|
|
67369
67492
|
|
|
67370
67493
|
|
|
@@ -67376,6 +67499,8 @@ const variables = ({ asMdx } = { asMdx: true }) => tree => {
|
|
|
67376
67499
|
|
|
67377
67500
|
|
|
67378
67501
|
|
|
67502
|
+
|
|
67503
|
+
|
|
67379
67504
|
/* harmony default export */ const transform = ([callouts, code_tabs, transform_embeds, transform_images, gemoji_]);
|
|
67380
67505
|
|
|
67381
67506
|
;// CONCATENATED MODULE: ./node_modules/rehype-slug/node_modules/github-slugger/regex.js
|
|
@@ -95920,6 +96045,10 @@ const compatibility = (node) => {
|
|
|
95920
96045
|
return figureToImageBlock(node);
|
|
95921
96046
|
case 'embed':
|
|
95922
96047
|
return embedToEmbedBlock(node);
|
|
96048
|
+
case 'i':
|
|
96049
|
+
return `:${node.data.hProperties.className[1]}:`;
|
|
96050
|
+
case 'yaml':
|
|
96051
|
+
return `---\n${node.value}\n---`;
|
|
95923
96052
|
default:
|
|
95924
96053
|
throw new Error('Unhandled node type!');
|
|
95925
96054
|
}
|
|
@@ -95957,6 +96086,8 @@ function compilers() {
|
|
|
95957
96086
|
escape: compile_compatibility,
|
|
95958
96087
|
figure: compile_compatibility,
|
|
95959
96088
|
html: compile_compatibility,
|
|
96089
|
+
i: compile_compatibility,
|
|
96090
|
+
yaml: compile_compatibility,
|
|
95960
96091
|
};
|
|
95961
96092
|
toMarkdownExtensions.push({ extensions: [{ handlers }] });
|
|
95962
96093
|
}
|
|
@@ -95975,7 +96106,9 @@ const mdx_mdx = (tree, { hast = false } = {}) => {
|
|
|
95975
96106
|
.use(hast ? rehypeRemark : undefined)
|
|
95976
96107
|
.use(remarkMdx)
|
|
95977
96108
|
.use(remarkGfm)
|
|
96109
|
+
.use(transform_div)
|
|
95978
96110
|
.use(readme_to_mdx)
|
|
96111
|
+
.use(tables_to_jsx)
|
|
95979
96112
|
.use(remarkStringify)
|
|
95980
96113
|
.use(processor_compile);
|
|
95981
96114
|
return processor.stringify(processor.runSync(tree));
|
|
@@ -38,6 +38,16 @@ type CompatNodes = {
|
|
|
38
38
|
value: string;
|
|
39
39
|
}];
|
|
40
40
|
}];
|
|
41
|
+
} | {
|
|
42
|
+
type: 'i';
|
|
43
|
+
data: {
|
|
44
|
+
hProperties: {
|
|
45
|
+
className: string[];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
type: 'yaml';
|
|
50
|
+
value: string;
|
|
41
51
|
} | Html;
|
|
42
52
|
declare const compatibility: (node: CompatNodes) => string;
|
|
43
53
|
export default compatibility;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import divTransformer from './div';
|
|
1
2
|
import injectComponents from './inject-components';
|
|
2
3
|
import readmeComponentsTransformer from './readme-components';
|
|
3
4
|
import readmeToMdx from './readme-to-mdx';
|
|
4
5
|
import variablesTransformer from './variables';
|
|
5
|
-
|
|
6
|
+
import tablesToJsx from './tables-to-jsx';
|
|
7
|
+
export { divTransformer, readmeComponentsTransformer, readmeToMdx, injectComponents, variablesTransformer, tablesToJsx, };
|
|
6
8
|
declare const _default: (() => (tree: any) => void)[];
|
|
7
9
|
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.
|
|
5
|
+
"version": "6.75.0-beta.71",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"lodash.escape": "^4.0.1",
|
|
41
41
|
"lodash.kebabcase": "^4.1.1",
|
|
42
42
|
"mdast-util-find-and-replace": "^3.0.1",
|
|
43
|
+
"mdast-util-phrasing": "^4.1.0",
|
|
43
44
|
"path-browserify": "^1.0.1",
|
|
44
45
|
"process": "^0.11.10",
|
|
45
46
|
"prop-types": "^15.8.1",
|