@readme/markdown 14.2.2 → 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 +39 -12
- package/dist/main.node.js +39 -12
- package/dist/main.node.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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__`,
|
|
@@ -72718,10 +72740,24 @@ const normalizeEmphasisAST = () => (tree) => {
|
|
|
72718
72740
|
visit(tree, 'text', function visitor(node, index, parent) {
|
|
72719
72741
|
if (index === undefined || !parent)
|
|
72720
72742
|
return undefined;
|
|
72721
|
-
// Skip if inside code blocks or
|
|
72743
|
+
// Skip if inside code blocks, inline code, or MDX JSX <code> elements.
|
|
72722
72744
|
if (parent.type === 'inlineCode' || parent.type === 'code') {
|
|
72723
72745
|
return undefined;
|
|
72724
72746
|
}
|
|
72747
|
+
// The parent type check for mdxJsxTextElement/mdxJsxFlowElement handles
|
|
72748
|
+
// raw HTML <code>...</code> inside table cells, which the table re-parser
|
|
72749
|
+
// parses as MDX JSX (not as an mdast `inlineCode` node).
|
|
72750
|
+
if ((parent.type === 'mdxJsxTextElement' || parent.type === 'mdxJsxFlowElement') &&
|
|
72751
|
+
'name' in parent && parent.name === 'code') {
|
|
72752
|
+
return undefined;
|
|
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
|
+
}
|
|
72725
72761
|
const text = node.value;
|
|
72726
72762
|
const allMatches = [];
|
|
72727
72763
|
[...text.matchAll(asteriskBoldRegex)].forEach(match => {
|
|
@@ -72958,16 +72994,7 @@ const parseTableNode = (processor, node) => {
|
|
|
72958
72994
|
* Check if children are only text nodes that might contain markdown
|
|
72959
72995
|
*/
|
|
72960
72996
|
const isTextOnly = (children) => {
|
|
72961
|
-
return children.every(child =>
|
|
72962
|
-
if (child && typeof child === 'object' && 'type' in child) {
|
|
72963
|
-
if (child.type === 'text')
|
|
72964
|
-
return true;
|
|
72965
|
-
if (child.type === 'mdxJsxTextElement' && 'children' in child && Array.isArray(child.children)) {
|
|
72966
|
-
return child.children.every((c) => c && typeof c === 'object' && 'type' in c && c.type === 'text');
|
|
72967
|
-
}
|
|
72968
|
-
}
|
|
72969
|
-
return false;
|
|
72970
|
-
});
|
|
72997
|
+
return children.every(child => child && typeof child === 'object' && 'type' in child && child.type === 'text');
|
|
72971
72998
|
};
|
|
72972
72999
|
/**
|
|
72973
73000
|
* Convenience wrapper that extracts text content from an array of children nodes.
|
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
|
-
|
|
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__`,
|
|
@@ -92912,10 +92934,24 @@ const normalizeEmphasisAST = () => (tree) => {
|
|
|
92912
92934
|
visit(tree, 'text', function visitor(node, index, parent) {
|
|
92913
92935
|
if (index === undefined || !parent)
|
|
92914
92936
|
return undefined;
|
|
92915
|
-
// Skip if inside code blocks or
|
|
92937
|
+
// Skip if inside code blocks, inline code, or MDX JSX <code> elements.
|
|
92916
92938
|
if (parent.type === 'inlineCode' || parent.type === 'code') {
|
|
92917
92939
|
return undefined;
|
|
92918
92940
|
}
|
|
92941
|
+
// The parent type check for mdxJsxTextElement/mdxJsxFlowElement handles
|
|
92942
|
+
// raw HTML <code>...</code> inside table cells, which the table re-parser
|
|
92943
|
+
// parses as MDX JSX (not as an mdast `inlineCode` node).
|
|
92944
|
+
if ((parent.type === 'mdxJsxTextElement' || parent.type === 'mdxJsxFlowElement') &&
|
|
92945
|
+
'name' in parent && parent.name === 'code') {
|
|
92946
|
+
return undefined;
|
|
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
|
+
}
|
|
92919
92955
|
const text = node.value;
|
|
92920
92956
|
const allMatches = [];
|
|
92921
92957
|
[...text.matchAll(asteriskBoldRegex)].forEach(match => {
|
|
@@ -93152,16 +93188,7 @@ const parseTableNode = (processor, node) => {
|
|
|
93152
93188
|
* Check if children are only text nodes that might contain markdown
|
|
93153
93189
|
*/
|
|
93154
93190
|
const isTextOnly = (children) => {
|
|
93155
|
-
return children.every(child =>
|
|
93156
|
-
if (child && typeof child === 'object' && 'type' in child) {
|
|
93157
|
-
if (child.type === 'text')
|
|
93158
|
-
return true;
|
|
93159
|
-
if (child.type === 'mdxJsxTextElement' && 'children' in child && Array.isArray(child.children)) {
|
|
93160
|
-
return child.children.every((c) => c && typeof c === 'object' && 'type' in c && c.type === 'text');
|
|
93161
|
-
}
|
|
93162
|
-
}
|
|
93163
|
-
return false;
|
|
93164
|
-
});
|
|
93191
|
+
return children.every(child => child && typeof child === 'object' && 'type' in child && child.type === 'text');
|
|
93165
93192
|
};
|
|
93166
93193
|
/**
|
|
93167
93194
|
* Convenience wrapper that extracts text content from an array of children nodes.
|