@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
package/dist/main.node.js
CHANGED
|
@@ -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";
|
|
@@ -19303,7 +19304,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
19303
19304
|
stripComments: () => (/* reexport */ lib_stripComments),
|
|
19304
19305
|
tags: () => (/* reexport */ lib_tags),
|
|
19305
19306
|
tailwindCompiler: () => (/* reexport */ tailwindCompiler),
|
|
19306
|
-
utils: () => (/* binding */
|
|
19307
|
+
utils: () => (/* binding */ index_utils)
|
|
19307
19308
|
});
|
|
19308
19309
|
|
|
19309
19310
|
// NAMESPACE OBJECT: ./components/index.ts
|
|
@@ -19625,16 +19626,16 @@ const Code = (props) => {
|
|
|
19625
19626
|
};
|
|
19626
19627
|
/* harmony default export */ const components_Code = (Code);
|
|
19627
19628
|
|
|
19628
|
-
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
|
|
19629
|
-
var
|
|
19630
|
-
var
|
|
19629
|
+
// EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/utils/index.js
|
|
19630
|
+
var utils = __webpack_require__(4350);
|
|
19631
|
+
var utils_default = /*#__PURE__*/__webpack_require__.n(utils);
|
|
19631
19632
|
;// ./components/CodeTabs/index.tsx
|
|
19632
19633
|
|
|
19633
19634
|
|
|
19634
19635
|
|
|
19635
19636
|
|
|
19636
19637
|
let mermaid;
|
|
19637
|
-
const { uppercase } = (
|
|
19638
|
+
const { uppercase } = (utils_default());
|
|
19638
19639
|
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
19639
19640
|
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
19640
19641
|
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
@@ -94657,11 +94658,6 @@ const looseHtmlEntityConstruct = {
|
|
|
94657
94658
|
name: 'looseHtmlEntity',
|
|
94658
94659
|
tokenize: tokenizeLooseHtmlEntity,
|
|
94659
94660
|
};
|
|
94660
|
-
function resolveEntity(name) {
|
|
94661
|
-
const input = `&${name};`;
|
|
94662
|
-
const decoded = decode_decodeHTMLStrict(input);
|
|
94663
|
-
return decoded !== input ? decoded : undefined;
|
|
94664
|
-
}
|
|
94665
94661
|
function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
94666
94662
|
let length = 0;
|
|
94667
94663
|
const start = (code) => {
|
|
@@ -94728,28 +94724,9 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
94728
94724
|
}
|
|
94729
94725
|
function exitLooseHtmlEntity(token) {
|
|
94730
94726
|
const raw = this.sliceSerialize(token);
|
|
94731
|
-
|
|
94732
|
-
|
|
94733
|
-
|
|
94734
|
-
if (decoded) {
|
|
94735
|
-
this.enter({ type: 'text', value: decoded }, token);
|
|
94736
|
-
this.exit(token);
|
|
94737
|
-
return;
|
|
94738
|
-
}
|
|
94739
|
-
}
|
|
94740
|
-
else {
|
|
94741
|
-
for (let len = entityChars.length; len >= 2; len -= 1) {
|
|
94742
|
-
const candidate = entityChars.slice(0, len);
|
|
94743
|
-
const decoded = resolveEntity(candidate);
|
|
94744
|
-
if (decoded) {
|
|
94745
|
-
const remainder = entityChars.slice(len);
|
|
94746
|
-
this.enter({ type: 'text', value: decoded + remainder }, token);
|
|
94747
|
-
this.exit(token);
|
|
94748
|
-
return;
|
|
94749
|
-
}
|
|
94750
|
-
}
|
|
94751
|
-
}
|
|
94752
|
-
this.enter({ type: 'text', value: raw }, token);
|
|
94727
|
+
// `decodeHTML` follows the HTML spec's legacy rules, where only a small
|
|
94728
|
+
// whitelist of names may omit the semicolon, so `&partner_key` stays intact.
|
|
94729
|
+
this.enter({ type: 'text', value: esm_decode_decodeHTML(raw) }, token);
|
|
94753
94730
|
this.exit(token);
|
|
94754
94731
|
}
|
|
94755
94732
|
function looseHtmlEntity() {
|
|
@@ -94769,10 +94746,11 @@ function looseHtmlEntityFromMarkdown() {
|
|
|
94769
94746
|
/**
|
|
94770
94747
|
* Micromark extension for HTML entities without semicolons.
|
|
94771
94748
|
*
|
|
94772
|
-
* Handles named entities
|
|
94773
|
-
*
|
|
94774
|
-
* `&#
|
|
94775
|
-
* standard parser
|
|
94749
|
+
* Handles the named entities the HTML spec lets authors write without a
|
|
94750
|
+
* semicolon (e.g. ` `, `&`, `©`), decimal numeric references (e.g.
|
|
94751
|
+
* ` `, `©`), and hex numeric references (e.g. ` `, ` `).
|
|
94752
|
+
* Entities that already include the semicolon are left for the standard parser
|
|
94753
|
+
* to handle.
|
|
94776
94754
|
*/
|
|
94777
94755
|
|
|
94778
94756
|
|
|
@@ -126552,9 +126530,9 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
|
|
|
126552
126530
|
properties[name] = name === 'style' && style_object_to_css_isPlainObject(result) ? styleObjectToCssText(result) : result;
|
|
126553
126531
|
}
|
|
126554
126532
|
catch {
|
|
126555
|
-
// Evaluation failed —
|
|
126556
|
-
//
|
|
126557
|
-
properties[name] = source
|
|
126533
|
+
// Evaluation failed — keep the literal `{...}`, matching how `evaluateExpressions` falls
|
|
126534
|
+
// back in body text. Variable references like `{user.name}` stay resolvable at render time.
|
|
126535
|
+
properties[name] = `{${source}}`;
|
|
126558
126536
|
}
|
|
126559
126537
|
});
|
|
126560
126538
|
delete node.data.deferredExpressions;
|
|
@@ -127460,6 +127438,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
|
|
|
127460
127438
|
};
|
|
127461
127439
|
/* harmony default export */ const contexts = (Contexts);
|
|
127462
127440
|
|
|
127441
|
+
;// ./utils/user.ts
|
|
127442
|
+
const User = (variables) => {
|
|
127443
|
+
const { user = {}, defaults = [] } = variables || {};
|
|
127444
|
+
return new Proxy(user, {
|
|
127445
|
+
get(target, attribute) {
|
|
127446
|
+
if (typeof attribute === 'symbol') {
|
|
127447
|
+
return '';
|
|
127448
|
+
}
|
|
127449
|
+
if (attribute in target) {
|
|
127450
|
+
return target[attribute];
|
|
127451
|
+
}
|
|
127452
|
+
const def = defaults.find((d) => d.name === attribute);
|
|
127453
|
+
return def ? def.default : attribute.toUpperCase();
|
|
127454
|
+
},
|
|
127455
|
+
});
|
|
127456
|
+
};
|
|
127457
|
+
/* harmony default export */ const user = (User);
|
|
127458
|
+
|
|
127463
127459
|
;// ./lib/utils/makeUseMdxComponents.ts
|
|
127464
127460
|
|
|
127465
127461
|
|
|
@@ -127490,6 +127486,35 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
127490
127486
|
};
|
|
127491
127487
|
/* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
|
|
127492
127488
|
|
|
127489
|
+
;// ./lib/utils/mdxish/mdxish-variables.ts
|
|
127490
|
+
|
|
127491
|
+
// The `$` guard skips template-literal interpolation: `${user.name}` embeds `{user.name}`, and
|
|
127492
|
+
// substituting it would leave a mangled `` `Hi $Name` `` behind. Those belong to an expression,
|
|
127493
|
+
// which either evaluated already or is meant to stay literal.
|
|
127494
|
+
const MDX_VARIABLE_REGEX = new RegExp(`(?<!\\$)${variable_dist.MDX_VARIABLE_REGEXP}`, 'gu');
|
|
127495
|
+
// Bracket notation names the same variable as dot notation, so normalize it before substituting.
|
|
127496
|
+
// Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
|
|
127497
|
+
// A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
|
|
127498
|
+
const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
|
|
127499
|
+
/**
|
|
127500
|
+
* Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
|
|
127501
|
+
* so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
|
|
127502
|
+
*
|
|
127503
|
+
* Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
|
|
127504
|
+
* an MDX surface, and `{user.*}` is the syntax authors use there.
|
|
127505
|
+
*/
|
|
127506
|
+
function resolveAttributeVariables(value, user) {
|
|
127507
|
+
if (!value.includes('{user'))
|
|
127508
|
+
return value;
|
|
127509
|
+
return value
|
|
127510
|
+
.replace(BRACKET_NOTATION_REGEX, '{user.$1}')
|
|
127511
|
+
.replace(MDX_VARIABLE_REGEX, (source, escapePrefix, name, escapeSuffix) => {
|
|
127512
|
+
if (escapePrefix || escapeSuffix)
|
|
127513
|
+
return source;
|
|
127514
|
+
return user[name];
|
|
127515
|
+
});
|
|
127516
|
+
}
|
|
127517
|
+
|
|
127493
127518
|
;// ./lib/utils/mdxish/mdxish-render-utils.tsx
|
|
127494
127519
|
|
|
127495
127520
|
|
|
@@ -127498,6 +127523,8 @@ const makeUseMDXComponents = (more = {}) => {
|
|
|
127498
127523
|
|
|
127499
127524
|
|
|
127500
127525
|
|
|
127526
|
+
|
|
127527
|
+
|
|
127501
127528
|
/** Flatten CustomComponents into a component map for rehype-react */
|
|
127502
127529
|
function exportComponentsForRehype(components) {
|
|
127503
127530
|
const exported = Object.entries(components).reduce((memo, [tag, mod]) => {
|
|
@@ -127525,6 +127552,28 @@ function exportComponentsForRehype(components) {
|
|
|
127525
127552
|
result.variable = (variable_dist_default());
|
|
127526
127553
|
return result;
|
|
127527
127554
|
}
|
|
127555
|
+
/**
|
|
127556
|
+
* Code rides on a `value` prop, and `variablesCodeResolver` owns it at parse time where it
|
|
127557
|
+
* deliberately leaves mermaid alone; resolving it again here would override that.
|
|
127558
|
+
*/
|
|
127559
|
+
const CODE_TAG_NAMES = new Set(['code']);
|
|
127560
|
+
/** Raw markup injected with `dangerouslySetInnerHTML` by HTMLBlock and Embed — never interpolate. */
|
|
127561
|
+
const RAW_HTML_PROP_NAMES = new Set(['html']);
|
|
127562
|
+
/**
|
|
127563
|
+
* Resolve `{user.*}` in string-valued props. Body text is handled by the `Variable` component, but
|
|
127564
|
+
* attributes are plain strings, so they are substituted here — at render time, so that a
|
|
127565
|
+
* server-parsed (user-agnostic) tree resolves against the current reader's variables.
|
|
127566
|
+
*/
|
|
127567
|
+
function resolveVariablesInProps(props, user, tagName) {
|
|
127568
|
+
const isCodeTag = Boolean(tagName && CODE_TAG_NAMES.has(tagName));
|
|
127569
|
+
const resolvedEntries = Object.entries(props).map(([key, value]) => {
|
|
127570
|
+
const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
|
|
127571
|
+
if (typeof value !== 'string' || isDocumentContent)
|
|
127572
|
+
return [key, value];
|
|
127573
|
+
return [key, resolveAttributeVariables(value, user)];
|
|
127574
|
+
});
|
|
127575
|
+
return Object.fromEntries(resolvedEntries);
|
|
127576
|
+
}
|
|
127528
127577
|
/**
|
|
127529
127578
|
* Custom React.createElement wrapper that recovers real JS prop values for
|
|
127530
127579
|
* custom components. rehype-react v6 uses hast-to-hyperscript, which stringifies
|
|
@@ -127536,7 +127585,7 @@ function exportComponentsForRehype(components) {
|
|
|
127536
127585
|
* Only arrays win over `rest`, overwriting other shapes would undo correct
|
|
127537
127586
|
* React conversions like `style="color:red"` → `{ color: 'red' }`.
|
|
127538
127587
|
*/
|
|
127539
|
-
function createElementPreservingHastProps(type, props, ...children) {
|
|
127588
|
+
const makeCreateElementPreservingHastProps = (user) => function createElementPreservingHastProps(type, props, ...children) {
|
|
127540
127589
|
if (props?.node?.properties) {
|
|
127541
127590
|
const { node, ...rest } = props;
|
|
127542
127591
|
const mergedProps = { ...rest };
|
|
@@ -127546,15 +127595,16 @@ function createElementPreservingHastProps(type, props, ...children) {
|
|
|
127546
127595
|
});
|
|
127547
127596
|
// Strip undefined so positional args don't shadow node.properties.children
|
|
127548
127597
|
const definedChildren = children.filter(c => c !== undefined);
|
|
127549
|
-
|
|
127598
|
+
const withVariables = resolveVariablesInProps(mergedProps, user, node.tagName);
|
|
127599
|
+
return external_react_default().createElement(type, withVariables, ...definedChildren);
|
|
127550
127600
|
}
|
|
127551
|
-
return external_react_default().createElement(type, props, ...children);
|
|
127552
|
-
}
|
|
127601
|
+
return external_react_default().createElement(type, props && resolveVariablesInProps(props, user), ...children);
|
|
127602
|
+
};
|
|
127553
127603
|
/** Create a rehype-react processor */
|
|
127554
|
-
function createRehypeReactProcessor(components) {
|
|
127604
|
+
function createRehypeReactProcessor(components, variables) {
|
|
127555
127605
|
// @ts-expect-error - rehype-react types are incompatible with React.Fragment return type
|
|
127556
127606
|
return unified().use((rehype_react_default()), {
|
|
127557
|
-
createElement:
|
|
127607
|
+
createElement: makeCreateElementPreservingHastProps(user(variables)),
|
|
127558
127608
|
Fragment: (external_react_default()).Fragment,
|
|
127559
127609
|
components,
|
|
127560
127610
|
passNode: true,
|
|
@@ -127569,7 +127619,7 @@ function createTocComponent(tocHast) {
|
|
|
127569
127619
|
components: { p: (external_react_default()).Fragment },
|
|
127570
127620
|
});
|
|
127571
127621
|
const tocReactElement = tocProcessor.stringify(tocHast);
|
|
127572
|
-
const TocComponent = () => tocReactElement ?
|
|
127622
|
+
const TocComponent = () => tocReactElement ? external_react_default().createElement(components_TableOfContents, null, tocReactElement) : null;
|
|
127573
127623
|
TocComponent.displayName = 'Toc';
|
|
127574
127624
|
return TocComponent;
|
|
127575
127625
|
}
|
|
@@ -127618,7 +127668,7 @@ const renderMdxish = (tree, opts = {}) => {
|
|
|
127618
127668
|
Object.entries(localScope).forEach(([name, value]) => {
|
|
127619
127669
|
componentsForRehype[name] = value;
|
|
127620
127670
|
});
|
|
127621
|
-
const processor = createRehypeReactProcessor(componentsForRehype);
|
|
127671
|
+
const processor = createRehypeReactProcessor(componentsForRehype, variables);
|
|
127622
127672
|
const content = processor.stringify(tree);
|
|
127623
127673
|
const tocHast = headings.length > 0 ? tocToHast(headings, variables) : null;
|
|
127624
127674
|
return buildRMDXModule(content, headings, tocHast, { ...contextOpts, variables });
|
|
@@ -127674,24 +127724,6 @@ function runSync(code, options) {
|
|
|
127674
127724
|
// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
|
|
127675
127725
|
var jsx_runtime = __webpack_require__(4848);
|
|
127676
127726
|
var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
|
|
127677
|
-
;// ./utils/user.ts
|
|
127678
|
-
const User = (variables) => {
|
|
127679
|
-
const { user = {}, defaults = [] } = variables || {};
|
|
127680
|
-
return new Proxy(user, {
|
|
127681
|
-
get(target, attribute) {
|
|
127682
|
-
if (typeof attribute === 'symbol') {
|
|
127683
|
-
return '';
|
|
127684
|
-
}
|
|
127685
|
-
if (attribute in target) {
|
|
127686
|
-
return target[attribute];
|
|
127687
|
-
}
|
|
127688
|
-
const def = defaults.find((d) => d.name === attribute);
|
|
127689
|
-
return def ? def.default : attribute.toUpperCase();
|
|
127690
|
-
},
|
|
127691
|
-
});
|
|
127692
|
-
};
|
|
127693
|
-
/* harmony default export */ const user = (User);
|
|
127694
|
-
|
|
127695
127727
|
;// ./lib/run.tsx
|
|
127696
127728
|
|
|
127697
127729
|
|
|
@@ -127936,7 +127968,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
127936
127968
|
|
|
127937
127969
|
|
|
127938
127970
|
|
|
127939
|
-
const
|
|
127971
|
+
const index_utils = {
|
|
127940
127972
|
get options() {
|
|
127941
127973
|
return { ...options };
|
|
127942
127974
|
},
|