@readme/markdown 12.0.1 → 12.1.0
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 +44 -41
- package/dist/main.node.js +44 -41
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/stripComments.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -52879,14 +52879,57 @@ function visualizeCharacterCode(charCode) {
|
|
|
52879
52879
|
return '0x' + charCode.toString(16).toUpperCase()
|
|
52880
52880
|
}
|
|
52881
52881
|
|
|
52882
|
+
;// ./processor/transform/stripComments.ts
|
|
52883
|
+
|
|
52884
|
+
const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
|
|
52885
|
+
const MDX_COMMENT_REGEX = /\/\*(?:(?!\*\/)[\s\S])*\*\//g;
|
|
52886
|
+
/**
|
|
52887
|
+
* A remark plugin to remove comments from Markdown and MDX.
|
|
52888
|
+
*/
|
|
52889
|
+
const stripCommentsTransformer = () => {
|
|
52890
|
+
return (tree) => {
|
|
52891
|
+
visit(tree, ['html', 'mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
|
|
52892
|
+
if (parent && typeof index === 'number') {
|
|
52893
|
+
// Remove HTML comments
|
|
52894
|
+
if (node.type === 'html' && HTML_COMMENT_REGEX.test(node.value)) {
|
|
52895
|
+
const newValue = node.value.replace(HTML_COMMENT_REGEX, '').trim();
|
|
52896
|
+
if (newValue) {
|
|
52897
|
+
node.value = newValue;
|
|
52898
|
+
}
|
|
52899
|
+
else {
|
|
52900
|
+
parent.children.splice(index, 1);
|
|
52901
|
+
return [SKIP, index];
|
|
52902
|
+
}
|
|
52903
|
+
}
|
|
52904
|
+
// Remove MDX comments
|
|
52905
|
+
if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
|
|
52906
|
+
MDX_COMMENT_REGEX.test(node.value)) {
|
|
52907
|
+
const newValue = node.value.replace(MDX_COMMENT_REGEX, '').trim();
|
|
52908
|
+
if (newValue) {
|
|
52909
|
+
node.value = newValue;
|
|
52910
|
+
}
|
|
52911
|
+
else {
|
|
52912
|
+
parent.children.splice(index, 1);
|
|
52913
|
+
return [SKIP, index];
|
|
52914
|
+
}
|
|
52915
|
+
}
|
|
52916
|
+
}
|
|
52917
|
+
return undefined;
|
|
52918
|
+
});
|
|
52919
|
+
};
|
|
52920
|
+
};
|
|
52921
|
+
|
|
52882
52922
|
;// ./lib/plain.ts
|
|
52883
52923
|
|
|
52924
|
+
|
|
52884
52925
|
const STRIP_TAGS = ['script', 'style'];
|
|
52885
52926
|
function plain_one(node, opts) {
|
|
52886
52927
|
if (node.type === 'comment')
|
|
52887
52928
|
return '';
|
|
52888
52929
|
if ('type' in node && node.type === 'text') {
|
|
52889
|
-
|
|
52930
|
+
// Remove all MDX comments from text nodes. We need this here because we
|
|
52931
|
+
// don't control whether comments are parsed into comment vs text nodes.
|
|
52932
|
+
return node.value.replace(MDX_COMMENT_REGEX, '');
|
|
52890
52933
|
}
|
|
52891
52934
|
if ('tagName' in node) {
|
|
52892
52935
|
if (STRIP_TAGS.includes(node.tagName))
|
|
@@ -95570,46 +95613,6 @@ const mdxishTags_tags = (doc) => {
|
|
|
95570
95613
|
};
|
|
95571
95614
|
/* harmony default export */ const mdxishTags = (mdxishTags_tags);
|
|
95572
95615
|
|
|
95573
|
-
;// ./processor/transform/stripComments.ts
|
|
95574
|
-
|
|
95575
|
-
const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
|
|
95576
|
-
const MDX_COMMENT_REGEX = /\/\*[\s\S]*?\*\//g;
|
|
95577
|
-
/**
|
|
95578
|
-
* A remark plugin to remove comments from Markdown and MDX.
|
|
95579
|
-
*/
|
|
95580
|
-
const stripCommentsTransformer = () => {
|
|
95581
|
-
return (tree) => {
|
|
95582
|
-
visit(tree, ['html', 'mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
|
|
95583
|
-
if (parent && typeof index === 'number') {
|
|
95584
|
-
// Remove HTML comments
|
|
95585
|
-
if (node.type === 'html' && HTML_COMMENT_REGEX.test(node.value)) {
|
|
95586
|
-
const newValue = node.value.replace(HTML_COMMENT_REGEX, '').trim();
|
|
95587
|
-
if (newValue) {
|
|
95588
|
-
node.value = newValue;
|
|
95589
|
-
}
|
|
95590
|
-
else {
|
|
95591
|
-
parent.children.splice(index, 1);
|
|
95592
|
-
return [SKIP, index];
|
|
95593
|
-
}
|
|
95594
|
-
}
|
|
95595
|
-
// Remove MDX comments
|
|
95596
|
-
if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
|
|
95597
|
-
MDX_COMMENT_REGEX.test(node.value)) {
|
|
95598
|
-
const newValue = node.value.replace(MDX_COMMENT_REGEX, '').trim();
|
|
95599
|
-
if (newValue) {
|
|
95600
|
-
node.value = newValue;
|
|
95601
|
-
}
|
|
95602
|
-
else {
|
|
95603
|
-
parent.children.splice(index, 1);
|
|
95604
|
-
return [SKIP, index];
|
|
95605
|
-
}
|
|
95606
|
-
}
|
|
95607
|
-
}
|
|
95608
|
-
return undefined;
|
|
95609
|
-
});
|
|
95610
|
-
};
|
|
95611
|
-
};
|
|
95612
|
-
|
|
95613
95616
|
;// ./lib/stripComments.ts
|
|
95614
95617
|
|
|
95615
95618
|
|
package/dist/main.node.js
CHANGED
|
@@ -73083,14 +73083,57 @@ function visualizeCharacterCode(charCode) {
|
|
|
73083
73083
|
return '0x' + charCode.toString(16).toUpperCase()
|
|
73084
73084
|
}
|
|
73085
73085
|
|
|
73086
|
+
;// ./processor/transform/stripComments.ts
|
|
73087
|
+
|
|
73088
|
+
const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
|
|
73089
|
+
const MDX_COMMENT_REGEX = /\/\*(?:(?!\*\/)[\s\S])*\*\//g;
|
|
73090
|
+
/**
|
|
73091
|
+
* A remark plugin to remove comments from Markdown and MDX.
|
|
73092
|
+
*/
|
|
73093
|
+
const stripCommentsTransformer = () => {
|
|
73094
|
+
return (tree) => {
|
|
73095
|
+
visit(tree, ['html', 'mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
|
|
73096
|
+
if (parent && typeof index === 'number') {
|
|
73097
|
+
// Remove HTML comments
|
|
73098
|
+
if (node.type === 'html' && HTML_COMMENT_REGEX.test(node.value)) {
|
|
73099
|
+
const newValue = node.value.replace(HTML_COMMENT_REGEX, '').trim();
|
|
73100
|
+
if (newValue) {
|
|
73101
|
+
node.value = newValue;
|
|
73102
|
+
}
|
|
73103
|
+
else {
|
|
73104
|
+
parent.children.splice(index, 1);
|
|
73105
|
+
return [SKIP, index];
|
|
73106
|
+
}
|
|
73107
|
+
}
|
|
73108
|
+
// Remove MDX comments
|
|
73109
|
+
if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
|
|
73110
|
+
MDX_COMMENT_REGEX.test(node.value)) {
|
|
73111
|
+
const newValue = node.value.replace(MDX_COMMENT_REGEX, '').trim();
|
|
73112
|
+
if (newValue) {
|
|
73113
|
+
node.value = newValue;
|
|
73114
|
+
}
|
|
73115
|
+
else {
|
|
73116
|
+
parent.children.splice(index, 1);
|
|
73117
|
+
return [SKIP, index];
|
|
73118
|
+
}
|
|
73119
|
+
}
|
|
73120
|
+
}
|
|
73121
|
+
return undefined;
|
|
73122
|
+
});
|
|
73123
|
+
};
|
|
73124
|
+
};
|
|
73125
|
+
|
|
73086
73126
|
;// ./lib/plain.ts
|
|
73087
73127
|
|
|
73128
|
+
|
|
73088
73129
|
const STRIP_TAGS = ['script', 'style'];
|
|
73089
73130
|
function plain_one(node, opts) {
|
|
73090
73131
|
if (node.type === 'comment')
|
|
73091
73132
|
return '';
|
|
73092
73133
|
if ('type' in node && node.type === 'text') {
|
|
73093
|
-
|
|
73134
|
+
// Remove all MDX comments from text nodes. We need this here because we
|
|
73135
|
+
// don't control whether comments are parsed into comment vs text nodes.
|
|
73136
|
+
return node.value.replace(MDX_COMMENT_REGEX, '');
|
|
73094
73137
|
}
|
|
73095
73138
|
if ('tagName' in node) {
|
|
73096
73139
|
if (STRIP_TAGS.includes(node.tagName))
|
|
@@ -115774,46 +115817,6 @@ const mdxishTags_tags = (doc) => {
|
|
|
115774
115817
|
};
|
|
115775
115818
|
/* harmony default export */ const mdxishTags = (mdxishTags_tags);
|
|
115776
115819
|
|
|
115777
|
-
;// ./processor/transform/stripComments.ts
|
|
115778
|
-
|
|
115779
|
-
const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
|
|
115780
|
-
const MDX_COMMENT_REGEX = /\/\*[\s\S]*?\*\//g;
|
|
115781
|
-
/**
|
|
115782
|
-
* A remark plugin to remove comments from Markdown and MDX.
|
|
115783
|
-
*/
|
|
115784
|
-
const stripCommentsTransformer = () => {
|
|
115785
|
-
return (tree) => {
|
|
115786
|
-
visit(tree, ['html', 'mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
|
|
115787
|
-
if (parent && typeof index === 'number') {
|
|
115788
|
-
// Remove HTML comments
|
|
115789
|
-
if (node.type === 'html' && HTML_COMMENT_REGEX.test(node.value)) {
|
|
115790
|
-
const newValue = node.value.replace(HTML_COMMENT_REGEX, '').trim();
|
|
115791
|
-
if (newValue) {
|
|
115792
|
-
node.value = newValue;
|
|
115793
|
-
}
|
|
115794
|
-
else {
|
|
115795
|
-
parent.children.splice(index, 1);
|
|
115796
|
-
return [SKIP, index];
|
|
115797
|
-
}
|
|
115798
|
-
}
|
|
115799
|
-
// Remove MDX comments
|
|
115800
|
-
if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
|
|
115801
|
-
MDX_COMMENT_REGEX.test(node.value)) {
|
|
115802
|
-
const newValue = node.value.replace(MDX_COMMENT_REGEX, '').trim();
|
|
115803
|
-
if (newValue) {
|
|
115804
|
-
node.value = newValue;
|
|
115805
|
-
}
|
|
115806
|
-
else {
|
|
115807
|
-
parent.children.splice(index, 1);
|
|
115808
|
-
return [SKIP, index];
|
|
115809
|
-
}
|
|
115810
|
-
}
|
|
115811
|
-
}
|
|
115812
|
-
return undefined;
|
|
115813
|
-
});
|
|
115814
|
-
};
|
|
115815
|
-
};
|
|
115816
|
-
|
|
115817
115820
|
;// ./lib/stripComments.ts
|
|
115818
115821
|
|
|
115819
115822
|
|