@readme/markdown 14.2.3 → 14.2.4

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
@@ -72005,7 +72005,8 @@ const imageTransformer = ({ isMdxish } = {}) => (tree) => {
72005
72005
  const isImageBlock = (node) => node.name === 'Image';
72006
72006
  visit(tree, isImageBlock, (node) => {
72007
72007
  const attrs = getAttrs(node);
72008
- if (attrs.caption) {
72008
+ // Mdxish handles caption parsing at the HAST stage via `rehypeMdxishComponents`
72009
+ if (attrs.caption && !isMdxish) {
72009
72010
  // @ts-expect-error - @todo: figure out how to coerce RootContent[] to
72010
72011
  // the correct type
72011
72012
  node.children = lib_mdast(attrs.caption).children;
@@ -72702,6 +72703,27 @@ function visitMultiNodeEmphasis(tree) {
72702
72703
  }
72703
72704
  });
72704
72705
  }
72706
+ /**
72707
+ * Returns true when the node at `index` inside `parent.children` sits between
72708
+ * sibling `html` nodes that form an inline `<code>…</code>` element.
72709
+ */
72710
+ function isInsideInlineHtmlCode(index, parent) {
72711
+ if (index === undefined || !Array.isArray(parent.children))
72712
+ return false;
72713
+ let i = index - 1;
72714
+ while (i >= 0) {
72715
+ const sibling = parent.children[i];
72716
+ if (sibling.type === 'html' && 'value' in sibling && typeof sibling.value === 'string') {
72717
+ const val = sibling.value.trim().toLowerCase();
72718
+ if (val === '<code>' || val.startsWith('<code ') || val.startsWith('<code\t'))
72719
+ return true;
72720
+ if (val === '</code>')
72721
+ return false;
72722
+ }
72723
+ i -= 1;
72724
+ }
72725
+ return false;
72726
+ }
72705
72727
  /**
72706
72728
  * A remark plugin that normalizes malformed bold and italic markers in text nodes.
72707
72729
  * Detects patterns like `** bold**`, `Hello** Wrong Bold**`, `__ bold__`, `Hello__ Wrong Bold__`,
@@ -72729,6 +72751,13 @@ const normalizeEmphasisAST = () => (tree) => {
72729
72751
  'name' in parent && parent.name === 'code') {
72730
72752
  return undefined;
72731
72753
  }
72754
+ // In GFM tables, inline <code>...</code> is represented as sibling `html`
72755
+ // nodes rather than as an mdxJsxTextElement, so the check above doesn't
72756
+ // apply. Scan backwards through siblings to see if we are enclosed by a
72757
+ // <code>…</code> inline HTML pair.
72758
+ if (isInsideInlineHtmlCode(index, parent)) {
72759
+ return undefined;
72760
+ }
72732
72761
  const text = node.value;
72733
72762
  const allMatches = [];
72734
72763
  [...text.matchAll(asteriskBoldRegex)].forEach(match => {
package/dist/main.node.js CHANGED
@@ -92199,7 +92199,8 @@ const imageTransformer = ({ isMdxish } = {}) => (tree) => {
92199
92199
  const isImageBlock = (node) => node.name === 'Image';
92200
92200
  visit(tree, isImageBlock, (node) => {
92201
92201
  const attrs = getAttrs(node);
92202
- if (attrs.caption) {
92202
+ // Mdxish handles caption parsing at the HAST stage via `rehypeMdxishComponents`
92203
+ if (attrs.caption && !isMdxish) {
92203
92204
  // @ts-expect-error - @todo: figure out how to coerce RootContent[] to
92204
92205
  // the correct type
92205
92206
  node.children = lib_mdast(attrs.caption).children;
@@ -92896,6 +92897,27 @@ function visitMultiNodeEmphasis(tree) {
92896
92897
  }
92897
92898
  });
92898
92899
  }
92900
+ /**
92901
+ * Returns true when the node at `index` inside `parent.children` sits between
92902
+ * sibling `html` nodes that form an inline `<code>…</code>` element.
92903
+ */
92904
+ function isInsideInlineHtmlCode(index, parent) {
92905
+ if (index === undefined || !Array.isArray(parent.children))
92906
+ return false;
92907
+ let i = index - 1;
92908
+ while (i >= 0) {
92909
+ const sibling = parent.children[i];
92910
+ if (sibling.type === 'html' && 'value' in sibling && typeof sibling.value === 'string') {
92911
+ const val = sibling.value.trim().toLowerCase();
92912
+ if (val === '<code>' || val.startsWith('<code ') || val.startsWith('<code\t'))
92913
+ return true;
92914
+ if (val === '</code>')
92915
+ return false;
92916
+ }
92917
+ i -= 1;
92918
+ }
92919
+ return false;
92920
+ }
92899
92921
  /**
92900
92922
  * A remark plugin that normalizes malformed bold and italic markers in text nodes.
92901
92923
  * Detects patterns like `** bold**`, `Hello** Wrong Bold**`, `__ bold__`, `Hello__ Wrong Bold__`,
@@ -92923,6 +92945,13 @@ const normalizeEmphasisAST = () => (tree) => {
92923
92945
  'name' in parent && parent.name === 'code') {
92924
92946
  return undefined;
92925
92947
  }
92948
+ // In GFM tables, inline <code>...</code> is represented as sibling `html`
92949
+ // nodes rather than as an mdxJsxTextElement, so the check above doesn't
92950
+ // apply. Scan backwards through siblings to see if we are enclosed by a
92951
+ // <code>…</code> inline HTML pair.
92952
+ if (isInsideInlineHtmlCode(index, parent)) {
92953
+ return undefined;
92954
+ }
92926
92955
  const text = node.value;
92927
92956
  const allMatches = [];
92928
92957
  [...text.matchAll(asteriskBoldRegex)].forEach(match => {