@readme/markdown 15.9.3 → 15.9.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/lib/mdast-util/mdx-expression/index.d.ts +3 -0
- package/dist/lib/micromark/mdxish-extensions.d.ts +3 -3
- package/dist/lib/utils/mdxish/mdxish-variables.d.ts +3 -2
- package/dist/main.js +66 -16
- package/dist/main.node.js +66 -16
- package/dist/main.node.js.map +1 -1
- package/dist/render-fixture.node.js +66 -16
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
|
@@ -19111,7 +19111,7 @@ module.exports = function () {
|
|
|
19111
19111
|
|
|
19112
19112
|
/***/ },
|
|
19113
19113
|
|
|
19114
|
-
/***/
|
|
19114
|
+
/***/ 7905
|
|
19115
19115
|
(module, __webpack_exports__, __webpack_require__) {
|
|
19116
19116
|
|
|
19117
19117
|
"use strict";
|
|
@@ -93266,6 +93266,26 @@ const mdxToHast = () => tree => {
|
|
|
93266
93266
|
};
|
|
93267
93267
|
/* harmony default export */ const mdx_to_hast = ((/* unused pure expression or super */ null && (mdxToHast)));
|
|
93268
93268
|
|
|
93269
|
+
;// ./lib/mdast-util/mdx-expression/index.ts
|
|
93270
|
+
|
|
93271
|
+
const upstream = mdxExpressionFromMarkdown();
|
|
93272
|
+
/**
|
|
93273
|
+
* An image's alt is its label flattened to text, which drops an expression's braces. Keep the
|
|
93274
|
+
* `{...}` source there so `{user.*}` still resolves in alt at render time (RM-10865).
|
|
93275
|
+
*/
|
|
93276
|
+
function exitTextExpression(token) {
|
|
93277
|
+
upstream.exit.mdxTextExpression.call(this, token);
|
|
93278
|
+
if (!this.stack.some(node => node.type === 'image'))
|
|
93279
|
+
return;
|
|
93280
|
+
const { children } = this.stack[this.stack.length - 1];
|
|
93281
|
+
const { position } = children[children.length - 1];
|
|
93282
|
+
children[children.length - 1] = { type: 'text', value: this.sliceSerialize(token), position };
|
|
93283
|
+
}
|
|
93284
|
+
/** Upstream `mdxExpressionFromMarkdown`, overriding only the text-expression exit to keep `{...}` source in image alt. */
|
|
93285
|
+
function mdxishExpressionFromMarkdown() {
|
|
93286
|
+
return { ...upstream, exit: { ...upstream.exit, mdxTextExpression: exitTextExpression } };
|
|
93287
|
+
}
|
|
93288
|
+
|
|
93269
93289
|
;// ./lib/mdast-util/empty-task-list-item/index.ts
|
|
93270
93290
|
/**
|
|
93271
93291
|
* Normalizes list items that are written as only `[ ]` or `[x]` into GFM task
|
|
@@ -93498,6 +93518,16 @@ function exitlegacyVariableValue(token) {
|
|
|
93498
93518
|
function exitlegacyVariable(token) {
|
|
93499
93519
|
const ctx = legacy_variable_contextMap.get(token);
|
|
93500
93520
|
const serialized = this.sliceSerialize(token);
|
|
93521
|
+
// An escaped `\<<name>>` (or `\<<name\>>`) is literal text, as in the legacy parser.
|
|
93522
|
+
if (serialized.startsWith('\\')) {
|
|
93523
|
+
const literal = serialized.slice(1).replace('\\>>', '>>');
|
|
93524
|
+
// An image's alt is flattened to a string, so keep the escape for render-time resolution to honor.
|
|
93525
|
+
const inImageAlt = this.stack.some(node => node.type === 'image');
|
|
93526
|
+
this.enter({ type: 'text', value: inImageAlt ? `\\${literal}` : literal }, token);
|
|
93527
|
+
this.exit(token);
|
|
93528
|
+
legacy_variable_contextMap.delete(token);
|
|
93529
|
+
return;
|
|
93530
|
+
}
|
|
93501
93531
|
const variableName = serialized.startsWith('<<') && serialized.endsWith('>>')
|
|
93502
93532
|
? serialized.slice(2, -2)
|
|
93503
93533
|
: ctx?.value ?? '';
|
|
@@ -95091,9 +95121,16 @@ const legacyVariableConstruct = {
|
|
|
95091
95121
|
function syntax_tokenize(effects, ok, nok) {
|
|
95092
95122
|
let hasValue = false;
|
|
95093
95123
|
const start = (code) => {
|
|
95124
|
+
effects.enter('legacyVariable');
|
|
95125
|
+
// Claim `\<<name>>` before CommonMark's character escape drops the backslash, as the legacy parser did.
|
|
95126
|
+
if (code !== codes.backslash)
|
|
95127
|
+
return open(code);
|
|
95128
|
+
effects.consume(code); // \
|
|
95129
|
+
return open;
|
|
95130
|
+
};
|
|
95131
|
+
const open = (code) => {
|
|
95094
95132
|
if (code !== codes.lessThan)
|
|
95095
95133
|
return nok(code);
|
|
95096
|
-
effects.enter('legacyVariable');
|
|
95097
95134
|
effects.enter('legacyVariableMarkerStart');
|
|
95098
95135
|
effects.consume(code); // <
|
|
95099
95136
|
return open2;
|
|
@@ -95133,7 +95170,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
95133
95170
|
}
|
|
95134
95171
|
function legacyVariable() {
|
|
95135
95172
|
return {
|
|
95136
|
-
text: { [codes.lessThan]: legacyVariableConstruct },
|
|
95173
|
+
text: { [codes.backslash]: legacyVariableConstruct, [codes.lessThan]: legacyVariableConstruct },
|
|
95137
95174
|
};
|
|
95138
95175
|
}
|
|
95139
95176
|
|
|
@@ -97457,12 +97494,12 @@ const REGISTRY = {
|
|
|
97457
97494
|
magicBlock: { syntax: magicBlock, fromMarkdown: magicBlockFromMarkdown },
|
|
97458
97495
|
// Two `{` tokenizers, never registered together: the document parser takes text
|
|
97459
97496
|
// only, the component-body re-parser needs flow too for multi-line expressions.
|
|
97460
|
-
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown:
|
|
97497
|
+
mdxExpressionLenient: { syntax: mdxExpressionLenient, fromMarkdown: mdxishExpressionFromMarkdown, expression: true },
|
|
97461
97498
|
// `allowEmpty` is the package default; passed explicitly because `mdx-jsx`
|
|
97462
97499
|
// registers the same tokenizer with it off for attribute expressions.
|
|
97463
97500
|
mdxExpression: {
|
|
97464
97501
|
syntax: () => mdxExpression({ allowEmpty: true }),
|
|
97465
|
-
fromMarkdown:
|
|
97502
|
+
fromMarkdown: mdxishExpressionFromMarkdown,
|
|
97466
97503
|
expression: true,
|
|
97467
97504
|
},
|
|
97468
97505
|
mdxComponent: { syntax: mdxComponent, fromMarkdown: mdxComponentFromMarkdown },
|
|
@@ -101062,6 +101099,7 @@ const splitHtmlWithNestedTables = (node, source) => {
|
|
|
101062
101099
|
|
|
101063
101100
|
|
|
101064
101101
|
|
|
101102
|
+
|
|
101065
101103
|
|
|
101066
101104
|
|
|
101067
101105
|
const isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
@@ -101082,9 +101120,13 @@ const buildTableNodeProcessor = (withMdx) => {
|
|
|
101082
101120
|
const { micromarkExtensions, fromMarkdownExtensions } = mdxishExtensions(FEATURES.tableCell);
|
|
101083
101121
|
// `mdxjs` goes first (= lowest priority): its `mdxJsx` also claims `text` + `<`,
|
|
101084
101122
|
// and `legacyVariable` has to keep winning that race so `<<var>>` still parses.
|
|
101123
|
+
// `mdxishExpressionFromMarkdown` follows `mdxFromMarkdown` to override its expression exit.
|
|
101085
101124
|
return unified()
|
|
101086
101125
|
.data('micromarkExtensions', [...(withMdx ? [mdxjs()] : []), ...micromarkExtensions])
|
|
101087
|
-
.data('fromMarkdownExtensions', [
|
|
101126
|
+
.data('fromMarkdownExtensions', [
|
|
101127
|
+
...(withMdx ? [mdxFromMarkdown(), mdxishExpressionFromMarkdown()] : []),
|
|
101128
|
+
...fromMarkdownExtensions,
|
|
101129
|
+
])
|
|
101088
101130
|
.use(remarkParse)
|
|
101089
101131
|
.use(normalize_malformed_md_syntax)
|
|
101090
101132
|
.use([[callouts, { isMdxish: true }], code_tabs])
|
|
@@ -127807,22 +127849,28 @@ const BARE_VARIABLE_REGEX = new RegExp(`^${variable_dist.MDX_VARIABLE_REGEXP}$`,
|
|
|
127807
127849
|
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
127808
127850
|
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
127809
127851
|
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
127852
|
+
const ALT_VARIABLE_REGEX = new RegExp(`${MDX_VARIABLE_REGEX.source}|${variable_dist.VARIABLE_REGEXP}`, 'gu');
|
|
127810
127853
|
/**
|
|
127811
127854
|
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
127812
127855
|
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
127813
127856
|
*
|
|
127814
127857
|
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
127815
|
-
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
127858
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there. Image alt is the exception, resolved
|
|
127859
|
+
* in the same pass so a substituted value is never rescanned (RM-10865).
|
|
127816
127860
|
*/
|
|
127817
|
-
function resolveAttributeVariables(value, user) {
|
|
127818
|
-
if (!value.includes('{user'))
|
|
127861
|
+
function resolveAttributeVariables(value, user, isImageAlt = false) {
|
|
127862
|
+
if (!isImageAlt && !value.includes('{user'))
|
|
127819
127863
|
return value;
|
|
127820
127864
|
return value
|
|
127821
127865
|
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
127822
|
-
.replace(MDX_VARIABLE_REGEX, (source,
|
|
127823
|
-
|
|
127824
|
-
|
|
127825
|
-
|
|
127866
|
+
.replace(isImageAlt ? ALT_VARIABLE_REGEX : MDX_VARIABLE_REGEX, (source, _prefix, name, _suffix, legacyName) => {
|
|
127867
|
+
// Variable names can't contain a backslash, so one marks an escaped reference.
|
|
127868
|
+
if (source.includes('\\'))
|
|
127869
|
+
return isImageAlt ? source.replaceAll('\\', '') : source;
|
|
127870
|
+
const key = (name ?? legacyName).trim();
|
|
127871
|
+
if (key.startsWith('glossary:'))
|
|
127872
|
+
return key.slice('glossary:'.length).trim();
|
|
127873
|
+
return stringifyVariableValue(user[key]);
|
|
127826
127874
|
});
|
|
127827
127875
|
}
|
|
127828
127876
|
/** Whether an attribute expression's source is a bare `user.*` reference, left for render-time substitution. */
|
|
@@ -128680,8 +128728,10 @@ function exportComponentsForRehype(components) {
|
|
|
128680
128728
|
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
128681
128729
|
*/
|
|
128682
128730
|
const CODE_TAG_NAMES = new Set(['code']);
|
|
128731
|
+
const isImageAlt = (tagName, key) => tagName === 'img' && key === 'alt';
|
|
128683
128732
|
/**
|
|
128684
|
-
* Resolve `{user.*}` in string-valued props
|
|
128733
|
+
* Resolve `{user.*}` in string-valued props, plus legacy `<<...>>` in img alt, where markdown flattens
|
|
128734
|
+
* body variables to text (RM-10865). Body text is handled by the `Variable` component, but
|
|
128685
128735
|
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
128686
128736
|
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
128687
128737
|
*/
|
|
@@ -128691,7 +128741,7 @@ function resolveVariablesInProps(props, user, tagName) {
|
|
|
128691
128741
|
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
128692
128742
|
if (typeof value !== 'string' || isDocumentContent)
|
|
128693
128743
|
return [key, value];
|
|
128694
|
-
return [key, resolveAttributeVariables(value, user)];
|
|
128744
|
+
return [key, resolveAttributeVariables(value, user, isImageAlt(tagName, key))];
|
|
128695
128745
|
});
|
|
128696
128746
|
return Object.fromEntries(resolvedEntries);
|
|
128697
128747
|
}
|
|
@@ -129526,7 +129576,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"*":["about","acceptCharset","accessK
|
|
|
129526
129576
|
/******/ // startup
|
|
129527
129577
|
/******/ // Load entry module and return exports
|
|
129528
129578
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
129529
|
-
/******/ let __webpack_exports__ = __webpack_require__(
|
|
129579
|
+
/******/ let __webpack_exports__ = __webpack_require__(7905);
|
|
129530
129580
|
/******/ module.exports = __webpack_exports__;
|
|
129531
129581
|
/******/
|
|
129532
129582
|
/******/ })()
|