@readme/markdown 14.14.2 → 15.0.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/368.node.js +1 -393
- package/dist/368.node.js.map +1 -1
- package/dist/lib/micromark/loose-html-entities/index.d.ts +5 -4
- package/dist/lib/utils/mdxish/mdxish-render-utils.d.ts +1 -1
- package/dist/lib/utils/mdxish/mdxish-variables.d.ts +8 -0
- package/dist/main.js +112 -80
- package/dist/main.node.js +105 -73
- package/dist/main.node.js.map +1 -1
- package/dist/render-fixture.node.js +103 -71
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +3 -2
|
@@ -275,7 +275,7 @@ function visit(tree, test, visitor, reverse) {
|
|
|
275
275
|
|
|
276
276
|
/***/ }),
|
|
277
277
|
|
|
278
|
-
/***/
|
|
278
|
+
/***/ 7644:
|
|
279
279
|
/***/ ((__unused_webpack_module, exports) => {
|
|
280
280
|
|
|
281
281
|
"use strict";
|
|
@@ -349,7 +349,7 @@ exports["default"] = canonical;
|
|
|
349
349
|
|
|
350
350
|
/***/ }),
|
|
351
351
|
|
|
352
|
-
/***/
|
|
352
|
+
/***/ 4350:
|
|
353
353
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
354
354
|
|
|
355
355
|
"use strict";
|
|
@@ -358,15 +358,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
358
358
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
359
359
|
};
|
|
360
360
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
361
|
-
const canonical_1 = __importDefault(__webpack_require__(
|
|
362
|
-
const modes_1 = __webpack_require__(
|
|
363
|
-
const uppercase_1 = __importDefault(__webpack_require__(
|
|
361
|
+
const canonical_1 = __importDefault(__webpack_require__(7644));
|
|
362
|
+
const modes_1 = __webpack_require__(1130);
|
|
363
|
+
const uppercase_1 = __importDefault(__webpack_require__(3622));
|
|
364
364
|
exports["default"] = { uppercase: uppercase_1.default, canonical: canonical_1.default, modes: modes_1.modes, getMode: modes_1.getMode };
|
|
365
365
|
|
|
366
366
|
|
|
367
367
|
/***/ }),
|
|
368
368
|
|
|
369
|
-
/***/
|
|
369
|
+
/***/ 1130:
|
|
370
370
|
/***/ ((__unused_webpack_module, exports) => {
|
|
371
371
|
|
|
372
372
|
"use strict";
|
|
@@ -425,6 +425,7 @@ exports.modes = {
|
|
|
425
425
|
node: 'javascript',
|
|
426
426
|
macruby: 'ruby',
|
|
427
427
|
markdown: 'gfm',
|
|
428
|
+
md: 'gfm',
|
|
428
429
|
ml: ['mllike', 'text/x-ocaml'],
|
|
429
430
|
mssql: ['sql', 'text/x-mssql'],
|
|
430
431
|
mysql: ['sql', 'text/x-mysql'],
|
|
@@ -479,7 +480,7 @@ function getMode(lang) {
|
|
|
479
480
|
|
|
480
481
|
/***/ }),
|
|
481
482
|
|
|
482
|
-
/***/
|
|
483
|
+
/***/ 3622:
|
|
483
484
|
/***/ ((__unused_webpack_module, exports) => {
|
|
484
485
|
|
|
485
486
|
"use strict";
|
|
@@ -86560,16 +86561,16 @@ const Code = (props) => {
|
|
|
86560
86561
|
};
|
|
86561
86562
|
/* harmony default export */ const components_Code = (Code);
|
|
86562
86563
|
|
|
86563
|
-
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
|
|
86564
|
-
var
|
|
86565
|
-
var
|
|
86564
|
+
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/utils/index.js
|
|
86565
|
+
var utils = __webpack_require__(4350);
|
|
86566
|
+
var utils_default = /*#__PURE__*/__webpack_require__.n(utils);
|
|
86566
86567
|
;// ./components/CodeTabs/index.tsx
|
|
86567
86568
|
|
|
86568
86569
|
|
|
86569
86570
|
|
|
86570
86571
|
|
|
86571
86572
|
let mermaid;
|
|
86572
|
-
const { uppercase } = (
|
|
86573
|
+
const { uppercase } = (utils_default());
|
|
86573
86574
|
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
86574
86575
|
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
86575
86576
|
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
@@ -94607,11 +94608,6 @@ const looseHtmlEntityConstruct = {
|
|
|
94607
94608
|
name: 'looseHtmlEntity',
|
|
94608
94609
|
tokenize: tokenizeLooseHtmlEntity,
|
|
94609
94610
|
};
|
|
94610
|
-
function resolveEntity(name) {
|
|
94611
|
-
const input = `&${name};`;
|
|
94612
|
-
const decoded = decode_decodeHTMLStrict(input);
|
|
94613
|
-
return decoded !== input ? decoded : undefined;
|
|
94614
|
-
}
|
|
94615
94611
|
function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
94616
94612
|
let length = 0;
|
|
94617
94613
|
const start = (code) => {
|
|
@@ -94678,28 +94674,9 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
94678
94674
|
}
|
|
94679
94675
|
function exitLooseHtmlEntity(token) {
|
|
94680
94676
|
const raw = this.sliceSerialize(token);
|
|
94681
|
-
|
|
94682
|
-
|
|
94683
|
-
|
|
94684
|
-
if (decoded) {
|
|
94685
|
-
this.enter({ type: 'text', value: decoded }, token);
|
|
94686
|
-
this.exit(token);
|
|
94687
|
-
return;
|
|
94688
|
-
}
|
|
94689
|
-
}
|
|
94690
|
-
else {
|
|
94691
|
-
for (let len = entityChars.length; len >= 2; len -= 1) {
|
|
94692
|
-
const candidate = entityChars.slice(0, len);
|
|
94693
|
-
const decoded = resolveEntity(candidate);
|
|
94694
|
-
if (decoded) {
|
|
94695
|
-
const remainder = entityChars.slice(len);
|
|
94696
|
-
this.enter({ type: 'text', value: decoded + remainder }, token);
|
|
94697
|
-
this.exit(token);
|
|
94698
|
-
return;
|
|
94699
|
-
}
|
|
94700
|
-
}
|
|
94701
|
-
}
|
|
94702
|
-
this.enter({ type: 'text', value: raw }, token);
|
|
94677
|
+
// `decodeHTML` follows the HTML spec's legacy rules, where only a small
|
|
94678
|
+
// whitelist of names may omit the semicolon, so `&partner_key` stays intact.
|
|
94679
|
+
this.enter({ type: 'text', value: esm_decode_decodeHTML(raw) }, token);
|
|
94703
94680
|
this.exit(token);
|
|
94704
94681
|
}
|
|
94705
94682
|
function looseHtmlEntity() {
|
|
@@ -94719,10 +94696,11 @@ function looseHtmlEntityFromMarkdown() {
|
|
|
94719
94696
|
/**
|
|
94720
94697
|
* Micromark extension for HTML entities without semicolons.
|
|
94721
94698
|
*
|
|
94722
|
-
* Handles named entities
|
|
94723
|
-
*
|
|
94724
|
-
* `&#
|
|
94725
|
-
* standard parser
|
|
94699
|
+
* Handles the named entities the HTML spec lets authors write without a
|
|
94700
|
+
* semicolon (e.g. ` `, `&`, `©`), decimal numeric references (e.g.
|
|
94701
|
+
* ` `, `©`), and hex numeric references (e.g. ` `, ` `).
|
|
94702
|
+
* Entities that already include the semicolon are left for the standard parser
|
|
94703
|
+
* to handle.
|
|
94726
94704
|
*/
|
|
94727
94705
|
|
|
94728
94706
|
|
|
@@ -126500,9 +126478,9 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
|
|
|
126500
126478
|
properties[name] = name === 'style' && style_object_to_css_isPlainObject(result) ? styleObjectToCssText(result) : result;
|
|
126501
126479
|
}
|
|
126502
126480
|
catch {
|
|
126503
|
-
// Evaluation failed —
|
|
126504
|
-
//
|
|
126505
|
-
properties[name] = source
|
|
126481
|
+
// Evaluation failed — keep the literal `{...}`, matching how `evaluateExpressions` falls
|
|
126482
|
+
// back in body text. Variable references like `{user.name}` stay resolvable at render time.
|
|
126483
|
+
properties[name] = `{${source}}`;
|
|
126506
126484
|
}
|
|
126507
126485
|
});
|
|
126508
126486
|
delete node.data.deferredExpressions;
|
|
@@ -127319,6 +127297,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
|
|
|
127319
127297
|
};
|
|
127320
127298
|
/* harmony default export */ const contexts = (Contexts);
|
|
127321
127299
|
|
|
127300
|
+
;// ./utils/user.ts
|
|
127301
|
+
const User = (variables) => {
|
|
127302
|
+
const { user = {}, defaults = [] } = variables || {};
|
|
127303
|
+
return new Proxy(user, {
|
|
127304
|
+
get(target, attribute) {
|
|
127305
|
+
if (typeof attribute === 'symbol') {
|
|
127306
|
+
return '';
|
|
127307
|
+
}
|
|
127308
|
+
if (attribute in target) {
|
|
127309
|
+
return target[attribute];
|
|
127310
|
+
}
|
|
127311
|
+
const def = defaults.find((d) => d.name === attribute);
|
|
127312
|
+
return def ? def.default : attribute.toUpperCase();
|
|
127313
|
+
},
|
|
127314
|
+
});
|
|
127315
|
+
};
|
|
127316
|
+
/* harmony default export */ const user = (User);
|
|
127317
|
+
|
|
127322
127318
|
;// ./lib/utils/makeUseMdxComponents.ts
|
|
127323
127319
|
|
|
127324
127320
|
|
|
@@ -127349,6 +127345,35 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
127349
127345
|
};
|
|
127350
127346
|
/* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
|
|
127351
127347
|
|
|
127348
|
+
;// ./lib/utils/mdxish/mdxish-variables.ts
|
|
127349
|
+
|
|
127350
|
+
// The `$` guard skips template-literal interpolation: `${user.name}` embeds `{user.name}`, and
|
|
127351
|
+
// substituting it would leave a mangled `` `Hi $Name` `` behind. Those belong to an expression,
|
|
127352
|
+
// which either evaluated already or is meant to stay literal.
|
|
127353
|
+
const MDX_VARIABLE_REGEX = new RegExp(`(?<!\\$)${variable_dist.MDX_VARIABLE_REGEXP}`, 'gu');
|
|
127354
|
+
// Bracket notation names the same variable as dot notation, so normalize it before substituting.
|
|
127355
|
+
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
127356
|
+
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
127357
|
+
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
127358
|
+
/**
|
|
127359
|
+
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
127360
|
+
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
127361
|
+
*
|
|
127362
|
+
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
127363
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
127364
|
+
*/
|
|
127365
|
+
function resolveAttributeVariables(value, user) {
|
|
127366
|
+
if (!value.includes('{user'))
|
|
127367
|
+
return value;
|
|
127368
|
+
return value
|
|
127369
|
+
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
127370
|
+
.replace(MDX_VARIABLE_REGEX, (source, escapePrefix, name, escapeSuffix) => {
|
|
127371
|
+
if (escapePrefix || escapeSuffix)
|
|
127372
|
+
return source;
|
|
127373
|
+
return user[name];
|
|
127374
|
+
});
|
|
127375
|
+
}
|
|
127376
|
+
|
|
127352
127377
|
;// ./lib/utils/mdxish/mdxish-render-utils.tsx
|
|
127353
127378
|
|
|
127354
127379
|
|
|
@@ -127357,6 +127382,8 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
127357
127382
|
|
|
127358
127383
|
|
|
127359
127384
|
|
|
127385
|
+
|
|
127386
|
+
|
|
127360
127387
|
/** Flatten CustomComponents into a component map for rehype-react */
|
|
127361
127388
|
function exportComponentsForRehype(components) {
|
|
127362
127389
|
const exported = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
@@ -127384,6 +127411,28 @@ function exportComponentsForRehype(components) {
|
|
|
127384
127411
|
result.variable = (variable_dist_default());
|
|
127385
127412
|
return result;
|
|
127386
127413
|
}
|
|
127414
|
+
/**
|
|
127415
|
+
* Code rides on a `value` prop, and `variablesCodeResolver` owns it at parse time where it
|
|
127416
|
+
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
127417
|
+
*/
|
|
127418
|
+
const CODE_TAG_NAMES = new Set(['code']);
|
|
127419
|
+
/** Raw markup injected with `dangerouslySetInnerHTML` by HTMLBlock and Embed — never interpolate. */
|
|
127420
|
+
const RAW_HTML_PROP_NAMES = new Set(['html']);
|
|
127421
|
+
/**
|
|
127422
|
+
* Resolve `{user.*}` in string-valued props. Body text is handled by the `Variable` component, but
|
|
127423
|
+
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
127424
|
+
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
127425
|
+
*/
|
|
127426
|
+
function resolveVariablesInProps(props, user, tagName) {
|
|
127427
|
+
const isCodeTag = Boolean(tagName && CODE_TAG_NAMES.has(tagName));
|
|
127428
|
+
const resolvedEntries = Object.entries(props).map(([key, value]) => {
|
|
127429
|
+
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
127430
|
+
if (typeof value !== 'string' || isDocumentContent)
|
|
127431
|
+
return [key, value];
|
|
127432
|
+
return [key, resolveAttributeVariables(value, user)];
|
|
127433
|
+
});
|
|
127434
|
+
return Object.fromEntries(resolvedEntries);
|
|
127435
|
+
}
|
|
127387
127436
|
/**
|
|
127388
127437
|
* Custom React.createElement wrapper that recovers real JS prop values for
|
|
127389
127438
|
* custom components. rehype-react v6 uses hast-to-hyperscript, which stringifies
|
|
@@ -127395,7 +127444,7 @@ function exportComponentsForRehype(components) {
|
|
|
127395
127444
|
* Only arrays win over `rest`, overwriting other shapes would undo correct
|
|
127396
127445
|
* React conversions like `style="color:red"` → `{ color: 'red' }`.
|
|
127397
127446
|
*/
|
|
127398
|
-
function createElementPreservingHastProps(type, props, ...children) {
|
|
127447
|
+
const makeCreateElementPreservingHastProps = (user) => function createElementPreservingHastProps(type, props, ...children) {
|
|
127399
127448
|
if (props?.node?.properties) {
|
|
127400
127449
|
const { node, ...rest } = props;
|
|
127401
127450
|
const mergedProps = { ...rest };
|
|
@@ -127405,15 +127454,16 @@ function createElementPreservingHastProps(type, props, ...children) {
|
|
|
127405
127454
|
});
|
|
127406
127455
|
// Strip undefined so positional args don't shadow node.properties.children
|
|
127407
127456
|
const definedChildren = children.filter(c => c !== undefined);
|
|
127408
|
-
|
|
127457
|
+
const withVariables = resolveVariablesInProps(mergedProps, user, node.tagName);
|
|
127458
|
+
return external_react_default().createElement(type, withVariables, ...definedChildren);
|
|
127409
127459
|
}
|
|
127410
|
-
return external_react_default().createElement(type, props, ...children);
|
|
127411
|
-
}
|
|
127460
|
+
return external_react_default().createElement(type, props && resolveVariablesInProps(props, user), ...children);
|
|
127461
|
+
};
|
|
127412
127462
|
/** Create a rehype-react processor */
|
|
127413
|
-
function createRehypeReactProcessor(components) {
|
|
127463
|
+
function createRehypeReactProcessor(components, variables) {
|
|
127414
127464
|
// @ts-expect-error - rehype-react types are incompatible with React.Fragment return type
|
|
127415
127465
|
return lib_unified().use((rehype_react_default()), {
|
|
127416
|
-
createElement:
|
|
127466
|
+
createElement: makeCreateElementPreservingHastProps(user(variables)),
|
|
127417
127467
|
Fragment: (external_react_default()).Fragment,
|
|
127418
127468
|
components,
|
|
127419
127469
|
passNode: true,
|
|
@@ -127428,7 +127478,7 @@ function createTocComponent(tocHast) {
|
|
|
127428
127478
|
components: { p: (external_react_default()).Fragment },
|
|
127429
127479
|
});
|
|
127430
127480
|
const tocReactElement = tocProcessor.stringify(tocHast);
|
|
127431
|
-
const TocComponent = () => tocReactElement ?
|
|
127481
|
+
const TocComponent = () => tocReactElement ? external_react_default().createElement(components_TableOfContents, null, tocReactElement) : null;
|
|
127432
127482
|
TocComponent.displayName = 'Toc';
|
|
127433
127483
|
return TocComponent;
|
|
127434
127484
|
}
|
|
@@ -127477,7 +127527,7 @@ const renderMdxish = (tree, opts = {}) => {
|
|
|
127477
127527
|
Object.entries(localScope).forEach(([name, value]) => {
|
|
127478
127528
|
componentsForRehype[name] = value;
|
|
127479
127529
|
});
|
|
127480
|
-
const processor = createRehypeReactProcessor(componentsForRehype);
|
|
127530
|
+
const processor = createRehypeReactProcessor(componentsForRehype, variables);
|
|
127481
127531
|
const content = processor.stringify(tree);
|
|
127482
127532
|
const tocHast = headings.length > 0 ? tocToHast(headings, variables) : null;
|
|
127483
127533
|
return buildRMDXModule(content, headings, tocHast, { ...contextOpts, variables });
|
|
@@ -127533,24 +127583,6 @@ function runSync(code, options) {
|
|
|
127533
127583
|
// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
|
|
127534
127584
|
var jsx_runtime = __webpack_require__(4848);
|
|
127535
127585
|
var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
|
|
127536
|
-
;// ./utils/user.ts
|
|
127537
|
-
const User = (variables) => {
|
|
127538
|
-
const { user = {}, defaults = [] } = variables || {};
|
|
127539
|
-
return new Proxy(user, {
|
|
127540
|
-
get(target, attribute) {
|
|
127541
|
-
if (typeof attribute === 'symbol') {
|
|
127542
|
-
return '';
|
|
127543
|
-
}
|
|
127544
|
-
if (attribute in target) {
|
|
127545
|
-
return target[attribute];
|
|
127546
|
-
}
|
|
127547
|
-
const def = defaults.find((d) => d.name === attribute);
|
|
127548
|
-
return def ? def.default : attribute.toUpperCase();
|
|
127549
|
-
},
|
|
127550
|
-
});
|
|
127551
|
-
};
|
|
127552
|
-
/* harmony default export */ const user = (User);
|
|
127553
|
-
|
|
127554
127586
|
;// ./lib/run.tsx
|
|
127555
127587
|
|
|
127556
127588
|
|