@readme/markdown 12.0.0 → 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 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
- return node.value;
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))
@@ -52957,6 +53000,11 @@ const extractText = (node) => {
52957
53000
  if (node.type === 'text' && typeof node.value === 'string') {
52958
53001
  return node.value;
52959
53002
  }
53003
+ // When a blockquote contains only an image (no text), treat it as having content
53004
+ // so the blockquote is no longer treated as empty and preserved correctly.
53005
+ if (node.type === 'image') {
53006
+ return typeof node.alt === 'string' && node.alt ? node.alt : '[image]';
53007
+ }
52960
53008
  if (node.children && Array.isArray(node.children)) {
52961
53009
  return node.children
52962
53010
  .map(child => {
@@ -95565,46 +95613,6 @@ const mdxishTags_tags = (doc) => {
95565
95613
  };
95566
95614
  /* harmony default export */ const mdxishTags = (mdxishTags_tags);
95567
95615
 
95568
- ;// ./processor/transform/stripComments.ts
95569
-
95570
- const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
95571
- const MDX_COMMENT_REGEX = /\/\*[\s\S]*?\*\//g;
95572
- /**
95573
- * A remark plugin to remove comments from Markdown and MDX.
95574
- */
95575
- const stripCommentsTransformer = () => {
95576
- return (tree) => {
95577
- visit(tree, ['html', 'mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
95578
- if (parent && typeof index === 'number') {
95579
- // Remove HTML comments
95580
- if (node.type === 'html' && HTML_COMMENT_REGEX.test(node.value)) {
95581
- const newValue = node.value.replace(HTML_COMMENT_REGEX, '').trim();
95582
- if (newValue) {
95583
- node.value = newValue;
95584
- }
95585
- else {
95586
- parent.children.splice(index, 1);
95587
- return [SKIP, index];
95588
- }
95589
- }
95590
- // Remove MDX comments
95591
- if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
95592
- MDX_COMMENT_REGEX.test(node.value)) {
95593
- const newValue = node.value.replace(MDX_COMMENT_REGEX, '').trim();
95594
- if (newValue) {
95595
- node.value = newValue;
95596
- }
95597
- else {
95598
- parent.children.splice(index, 1);
95599
- return [SKIP, index];
95600
- }
95601
- }
95602
- }
95603
- return undefined;
95604
- });
95605
- };
95606
- };
95607
-
95608
95616
  ;// ./lib/stripComments.ts
95609
95617
 
95610
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
- return node.value;
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))
@@ -73161,6 +73204,11 @@ const extractText = (node) => {
73161
73204
  if (node.type === 'text' && typeof node.value === 'string') {
73162
73205
  return node.value;
73163
73206
  }
73207
+ // When a blockquote contains only an image (no text), treat it as having content
73208
+ // so the blockquote is no longer treated as empty and preserved correctly.
73209
+ if (node.type === 'image') {
73210
+ return typeof node.alt === 'string' && node.alt ? node.alt : '[image]';
73211
+ }
73164
73212
  if (node.children && Array.isArray(node.children)) {
73165
73213
  return node.children
73166
73214
  .map(child => {
@@ -115769,46 +115817,6 @@ const mdxishTags_tags = (doc) => {
115769
115817
  };
115770
115818
  /* harmony default export */ const mdxishTags = (mdxishTags_tags);
115771
115819
 
115772
- ;// ./processor/transform/stripComments.ts
115773
-
115774
- const HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
115775
- const MDX_COMMENT_REGEX = /\/\*[\s\S]*?\*\//g;
115776
- /**
115777
- * A remark plugin to remove comments from Markdown and MDX.
115778
- */
115779
- const stripCommentsTransformer = () => {
115780
- return (tree) => {
115781
- visit(tree, ['html', 'mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
115782
- if (parent && typeof index === 'number') {
115783
- // Remove HTML comments
115784
- if (node.type === 'html' && HTML_COMMENT_REGEX.test(node.value)) {
115785
- const newValue = node.value.replace(HTML_COMMENT_REGEX, '').trim();
115786
- if (newValue) {
115787
- node.value = newValue;
115788
- }
115789
- else {
115790
- parent.children.splice(index, 1);
115791
- return [SKIP, index];
115792
- }
115793
- }
115794
- // Remove MDX comments
115795
- if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
115796
- MDX_COMMENT_REGEX.test(node.value)) {
115797
- const newValue = node.value.replace(MDX_COMMENT_REGEX, '').trim();
115798
- if (newValue) {
115799
- node.value = newValue;
115800
- }
115801
- else {
115802
- parent.children.splice(index, 1);
115803
- return [SKIP, index];
115804
- }
115805
- }
115806
- }
115807
- return undefined;
115808
- });
115809
- };
115810
- };
115811
-
115812
115820
  ;// ./lib/stripComments.ts
115813
115821
 
115814
115822