@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/main.js CHANGED
@@ -285,7 +285,7 @@ function visit(tree, test, visitor, reverse) {
285
285
 
286
286
  /***/ }),
287
287
 
288
- /***/ 9762:
288
+ /***/ 7644:
289
289
  /***/ ((__unused_webpack_module, exports) => {
290
290
 
291
291
  "use strict";
@@ -359,7 +359,7 @@ exports["default"] = canonical;
359
359
 
360
360
  /***/ }),
361
361
 
362
- /***/ 7900:
362
+ /***/ 4350:
363
363
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
364
364
 
365
365
  "use strict";
@@ -368,15 +368,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
368
368
  return (mod && mod.__esModule) ? mod : { "default": mod };
369
369
  };
370
370
  Object.defineProperty(exports, "__esModule", ({ value: true }));
371
- const canonical_1 = __importDefault(__webpack_require__(9762));
372
- const modes_1 = __webpack_require__(1412);
373
- const uppercase_1 = __importDefault(__webpack_require__(8892));
371
+ const canonical_1 = __importDefault(__webpack_require__(7644));
372
+ const modes_1 = __webpack_require__(1130);
373
+ const uppercase_1 = __importDefault(__webpack_require__(3622));
374
374
  exports["default"] = { uppercase: uppercase_1.default, canonical: canonical_1.default, modes: modes_1.modes, getMode: modes_1.getMode };
375
375
 
376
376
 
377
377
  /***/ }),
378
378
 
379
- /***/ 1412:
379
+ /***/ 1130:
380
380
  /***/ ((__unused_webpack_module, exports) => {
381
381
 
382
382
  "use strict";
@@ -435,6 +435,7 @@ exports.modes = {
435
435
  node: 'javascript',
436
436
  macruby: 'ruby',
437
437
  markdown: 'gfm',
438
+ md: 'gfm',
438
439
  ml: ['mllike', 'text/x-ocaml'],
439
440
  mssql: ['sql', 'text/x-mssql'],
440
441
  mysql: ['sql', 'text/x-mysql'],
@@ -489,7 +490,7 @@ function getMode(lang) {
489
490
 
490
491
  /***/ }),
491
492
 
492
- /***/ 8892:
493
+ /***/ 3622:
493
494
  /***/ ((__unused_webpack_module, exports) => {
494
495
 
495
496
  "use strict";
@@ -1517,7 +1518,7 @@ module.exports = function (key) {
1517
1518
 
1518
1519
  /***/ }),
1519
1520
 
1520
- /***/ 1847:
1521
+ /***/ 4228:
1521
1522
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1522
1523
 
1523
1524
  var isObject = __webpack_require__(3305);
@@ -2213,7 +2214,7 @@ var meta = module.exports = {
2213
2214
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2214
2215
 
2215
2216
  // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
2216
- var anObject = __webpack_require__(1847);
2217
+ var anObject = __webpack_require__(4228);
2217
2218
  var dPs = __webpack_require__(1626);
2218
2219
  var enumBugKeys = __webpack_require__(6140);
2219
2220
  var IE_PROTO = __webpack_require__(766)('IE_PROTO');
@@ -2260,7 +2261,7 @@ module.exports = Object.create || function create(O, Properties) {
2260
2261
  /***/ 7967:
2261
2262
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2262
2263
 
2263
- var anObject = __webpack_require__(1847);
2264
+ var anObject = __webpack_require__(4228);
2264
2265
  var IE8_DOM_DEFINE = __webpack_require__(2956);
2265
2266
  var toPrimitive = __webpack_require__(3048);
2266
2267
  var dP = Object.defineProperty;
@@ -2284,7 +2285,7 @@ exports.f = __webpack_require__(1763) ? Object.defineProperty : function defineP
2284
2285
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2285
2286
 
2286
2287
  var dP = __webpack_require__(7967);
2287
- var anObject = __webpack_require__(1847);
2288
+ var anObject = __webpack_require__(4228);
2288
2289
  var getKeys = __webpack_require__(1311);
2289
2290
 
2290
2291
  module.exports = __webpack_require__(1763) ? Object.defineProperties : function defineProperties(O, Properties) {
@@ -2460,7 +2461,7 @@ module.exports = function (KEY, exec) {
2460
2461
  // all object keys, includes non-enumerable and symbols
2461
2462
  var gOPN = __webpack_require__(9415);
2462
2463
  var gOPS = __webpack_require__(1060);
2463
- var anObject = __webpack_require__(1847);
2464
+ var anObject = __webpack_require__(4228);
2464
2465
  var Reflect = (__webpack_require__(7526).Reflect);
2465
2466
  module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {
2466
2467
  var keys = gOPN.f(anObject(it));
@@ -2530,7 +2531,7 @@ var TPL = ('' + $toString).split(TO_STRING);
2530
2531
  // Works with __proto__ only. Old v8 can't work with null proto objects.
2531
2532
  /* eslint-disable no-proto */
2532
2533
  var isObject = __webpack_require__(3305);
2533
- var anObject = __webpack_require__(1847);
2534
+ var anObject = __webpack_require__(4228);
2534
2535
  var check = function (O, proto) {
2535
2536
  anObject(O);
2536
2537
  if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
@@ -3133,7 +3134,7 @@ var wksExt = __webpack_require__(7960);
3133
3134
  var wksDefine = __webpack_require__(5392);
3134
3135
  var enumKeys = __webpack_require__(5969);
3135
3136
  var isArray = __webpack_require__(7981);
3136
- var anObject = __webpack_require__(1847);
3137
+ var anObject = __webpack_require__(4228);
3137
3138
  var isObject = __webpack_require__(3305);
3138
3139
  var toObject = __webpack_require__(8270);
3139
3140
  var toIObject = __webpack_require__(7221);
@@ -11619,7 +11620,7 @@ __webpack_require__.d(__webpack_exports__, {
11619
11620
  stripComments: () => (/* reexport */ lib_stripComments),
11620
11621
  tags: () => (/* reexport */ lib_tags),
11621
11622
  tailwindCompiler: () => (/* reexport */ tailwindCompiler),
11622
- utils: () => (/* binding */ utils)
11623
+ utils: () => (/* binding */ index_utils)
11623
11624
  });
11624
11625
 
11625
11626
  // NAMESPACE OBJECT: ./components/index.ts
@@ -11941,16 +11942,16 @@ const Code = (props) => {
11941
11942
  };
11942
11943
  /* harmony default export */ const components_Code = (Code);
11943
11944
 
11944
- // EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/index.js
11945
- var dist_utils = __webpack_require__(7900);
11946
- var dist_utils_default = /*#__PURE__*/__webpack_require__.n(dist_utils);
11945
+ // EXTERNAL MODULE: ./node_modules/@readme/syntax-highlighter/dist-utils/utils/index.js
11946
+ var utils = __webpack_require__(4350);
11947
+ var utils_default = /*#__PURE__*/__webpack_require__.n(utils);
11947
11948
  ;// ./components/CodeTabs/index.tsx
11948
11949
 
11949
11950
 
11950
11951
 
11951
11952
 
11952
11953
  let mermaid;
11953
- const { uppercase } = (dist_utils_default());
11954
+ const { uppercase } = (utils_default());
11954
11955
  // Module-level queue that batches mermaid nodes across all CodeTabs instances into a
11955
11956
  // single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
11956
11957
  // using Date.now(), which collides when multiple diagrams render in the same millisecond.
@@ -74433,11 +74434,6 @@ const looseHtmlEntityConstruct = {
74433
74434
  name: 'looseHtmlEntity',
74434
74435
  tokenize: tokenizeLooseHtmlEntity,
74435
74436
  };
74436
- function resolveEntity(name) {
74437
- const input = `&${name};`;
74438
- const decoded = decode_decodeHTMLStrict(input);
74439
- return decoded !== input ? decoded : undefined;
74440
- }
74441
74437
  function tokenizeLooseHtmlEntity(effects, ok, nok) {
74442
74438
  let length = 0;
74443
74439
  const start = (code) => {
@@ -74504,28 +74500,9 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
74504
74500
  }
74505
74501
  function exitLooseHtmlEntity(token) {
74506
74502
  const raw = this.sliceSerialize(token);
74507
- const entityChars = raw.slice(1);
74508
- if (entityChars.startsWith('#')) {
74509
- const decoded = resolveEntity(entityChars);
74510
- if (decoded) {
74511
- this.enter({ type: 'text', value: decoded }, token);
74512
- this.exit(token);
74513
- return;
74514
- }
74515
- }
74516
- else {
74517
- for (let len = entityChars.length; len >= 2; len -= 1) {
74518
- const candidate = entityChars.slice(0, len);
74519
- const decoded = resolveEntity(candidate);
74520
- if (decoded) {
74521
- const remainder = entityChars.slice(len);
74522
- this.enter({ type: 'text', value: decoded + remainder }, token);
74523
- this.exit(token);
74524
- return;
74525
- }
74526
- }
74527
- }
74528
- this.enter({ type: 'text', value: raw }, token);
74503
+ // `decodeHTML` follows the HTML spec's legacy rules, where only a small
74504
+ // whitelist of names may omit the semicolon, so `&partner_key` stays intact.
74505
+ this.enter({ type: 'text', value: esm_decode_decodeHTML(raw) }, token);
74529
74506
  this.exit(token);
74530
74507
  }
74531
74508
  function looseHtmlEntity() {
@@ -74545,10 +74522,11 @@ function looseHtmlEntityFromMarkdown() {
74545
74522
  /**
74546
74523
  * Micromark extension for HTML entities without semicolons.
74547
74524
  *
74548
- * Handles named entities (e.g. `&nbsp`, `&amp`, `&copy`), decimal numeric
74549
- * references (e.g. `&#160`, `&#169`), and hex numeric references (e.g. `&#xa0`,
74550
- * `&#xA0`). Entities that already include the semicolon are left for the
74551
- * standard parser to handle.
74525
+ * Handles the named entities the HTML spec lets authors write without a
74526
+ * semicolon (e.g. `&nbsp`, `&amp`, `&copy`), decimal numeric references (e.g.
74527
+ * `&#160`, `&#169`), and hex numeric references (e.g. `&#xa0`, `&#xA0`).
74528
+ * Entities that already include the semicolon are left for the standard parser
74529
+ * to handle.
74552
74530
  */
74553
74531
 
74554
74532
 
@@ -106328,9 +106306,9 @@ const resolveDeferredAttributeExpressionProps = () => (tree, file) => {
106328
106306
  properties[name] = name === 'style' && style_object_to_css_isPlainObject(result) ? styleObjectToCssText(result) : result;
106329
106307
  }
106330
106308
  catch {
106331
- // Evaluation failed — fall back to the raw expression source so the attribute
106332
- // renders as readable text rather than disappearing.
106333
- properties[name] = source;
106309
+ // Evaluation failed — keep the literal `{...}`, matching how `evaluateExpressions` falls
106310
+ // back in body text. Variable references like `{user.name}` stay resolvable at render time.
106311
+ properties[name] = `{${source}}`;
106334
106312
  }
106335
106313
  });
106336
106314
  delete node.data.deferredExpressions;
@@ -107236,6 +107214,24 @@ const Contexts = ({ children, terms = [], variables = { user: {}, defaults: [] }
107236
107214
  };
107237
107215
  /* harmony default export */ const contexts = (Contexts);
107238
107216
 
107217
+ ;// ./utils/user.ts
107218
+ const User = (variables) => {
107219
+ const { user = {}, defaults = [] } = variables || {};
107220
+ return new Proxy(user, {
107221
+ get(target, attribute) {
107222
+ if (typeof attribute === 'symbol') {
107223
+ return '';
107224
+ }
107225
+ if (attribute in target) {
107226
+ return target[attribute];
107227
+ }
107228
+ const def = defaults.find((d) => d.name === attribute);
107229
+ return def ? def.default : attribute.toUpperCase();
107230
+ },
107231
+ });
107232
+ };
107233
+ /* harmony default export */ const user = (User);
107234
+
107239
107235
  ;// ./lib/utils/makeUseMdxComponents.ts
107240
107236
 
107241
107237
 
@@ -107266,6 +107262,35 @@ const makeUseMDXComponents = (more = {}) => {
107266
107262
  };
107267
107263
  /* harmony default export */ const makeUseMdxComponents = (makeUseMDXComponents);
107268
107264
 
107265
+ ;// ./lib/utils/mdxish/mdxish-variables.ts
107266
+
107267
+ // The `$` guard skips template-literal interpolation: `${user.name}` embeds `{user.name}`, and
107268
+ // substituting it would leave a mangled `` `Hi $Name` `` behind. Those belong to an expression,
107269
+ // which either evaluated already or is meant to stay literal.
107270
+ const MDX_VARIABLE_REGEX = new RegExp(`(?<!\\$)${variable_.MDX_VARIABLE_REGEXP}`, 'gu');
107271
+ // Bracket notation names the same variable as dot notation, so normalize it before substituting.
107272
+ // Escaped and `$`-prefixed forms are left alone so a reference that stays literal keeps its source.
107273
+ // A closing escape needs no lookahead: requiring a literal `]}` already rules out `]\}`.
107274
+ const BRACKET_NOTATION_REGEX = /(?<![$\\])\{user\[['"](\w+)['"]\]\}/gu;
107275
+ /**
107276
+ * Resolve `{user.*}` in a JSX attribute value against the same `user` binding the rmdx engine gets,
107277
+ * so both engines agree. Body text differs on empty values: `Variable` falls back to the default.
107278
+ *
107279
+ * Legacy `<<...>>` is valid inside a quoted attribute but deliberately left literal — attributes are
107280
+ * an MDX surface, and `{user.*}` is the syntax authors use there.
107281
+ */
107282
+ function resolveAttributeVariables(value, user) {
107283
+ if (!value.includes('{user'))
107284
+ return value;
107285
+ return value
107286
+ .replace(BRACKET_NOTATION_REGEX, '{user.$1}')
107287
+ .replace(MDX_VARIABLE_REGEX, (source, escapePrefix, name, escapeSuffix) => {
107288
+ if (escapePrefix || escapeSuffix)
107289
+ return source;
107290
+ return user[name];
107291
+ });
107292
+ }
107293
+
107269
107294
  ;// ./lib/utils/mdxish/mdxish-render-utils.tsx
107270
107295
 
107271
107296
 
@@ -107274,6 +107299,8 @@ const makeUseMDXComponents = (more = {}) => {
107274
107299
 
107275
107300
 
107276
107301
 
107302
+
107303
+
107277
107304
  /** Flatten CustomComponents into a component map for rehype-react */
107278
107305
  function exportComponentsForRehype(components) {
107279
107306
  const exported = Object.entries(components).reduce((memo, [tag, mod]) => {
@@ -107301,6 +107328,28 @@ function exportComponentsForRehype(components) {
107301
107328
  result.variable = (variable_default());
107302
107329
  return result;
107303
107330
  }
107331
+ /**
107332
+ * Code rides on a `value` prop, and `variablesCodeResolver` owns it at parse time where it
107333
+ * deliberately leaves mermaid alone; resolving it again here would override that.
107334
+ */
107335
+ const CODE_TAG_NAMES = new Set(['code']);
107336
+ /** Raw markup injected with `dangerouslySetInnerHTML` by HTMLBlock and Embed — never interpolate. */
107337
+ const RAW_HTML_PROP_NAMES = new Set(['html']);
107338
+ /**
107339
+ * Resolve `{user.*}` in string-valued props. Body text is handled by the `Variable` component, but
107340
+ * attributes are plain strings, so they are substituted here — at render time, so that a
107341
+ * server-parsed (user-agnostic) tree resolves against the current reader's variables.
107342
+ */
107343
+ function resolveVariablesInProps(props, user, tagName) {
107344
+ const isCodeTag = Boolean(tagName && CODE_TAG_NAMES.has(tagName));
107345
+ const resolvedEntries = Object.entries(props).map(([key, value]) => {
107346
+ const isDocumentContent = RAW_HTML_PROP_NAMES.has(key) || (isCodeTag && key === 'value');
107347
+ if (typeof value !== 'string' || isDocumentContent)
107348
+ return [key, value];
107349
+ return [key, resolveAttributeVariables(value, user)];
107350
+ });
107351
+ return Object.fromEntries(resolvedEntries);
107352
+ }
107304
107353
  /**
107305
107354
  * Custom React.createElement wrapper that recovers real JS prop values for
107306
107355
  * custom components. rehype-react v6 uses hast-to-hyperscript, which stringifies
@@ -107312,7 +107361,7 @@ function exportComponentsForRehype(components) {
107312
107361
  * Only arrays win over `rest`, overwriting other shapes would undo correct
107313
107362
  * React conversions like `style="color:red"` → `{ color: 'red' }`.
107314
107363
  */
107315
- function createElementPreservingHastProps(type, props, ...children) {
107364
+ const makeCreateElementPreservingHastProps = (user) => function createElementPreservingHastProps(type, props, ...children) {
107316
107365
  if (props?.node?.properties) {
107317
107366
  const { node, ...rest } = props;
107318
107367
  const mergedProps = { ...rest };
@@ -107322,15 +107371,16 @@ function createElementPreservingHastProps(type, props, ...children) {
107322
107371
  });
107323
107372
  // Strip undefined so positional args don't shadow node.properties.children
107324
107373
  const definedChildren = children.filter(c => c !== undefined);
107325
- return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, mergedProps, ...definedChildren);
107374
+ const withVariables = resolveVariablesInProps(mergedProps, user, node.tagName);
107375
+ return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, withVariables, ...definedChildren);
107326
107376
  }
107327
- return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, props, ...children);
107328
- }
107377
+ return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(type, props && resolveVariablesInProps(props, user), ...children);
107378
+ };
107329
107379
  /** Create a rehype-react processor */
107330
- function createRehypeReactProcessor(components) {
107380
+ function createRehypeReactProcessor(components, variables) {
107331
107381
  // @ts-expect-error - rehype-react types are incompatible with React.Fragment return type
107332
107382
  return unified().use((rehype_react_default()), {
107333
- createElement: createElementPreservingHastProps,
107383
+ createElement: makeCreateElementPreservingHastProps(user(variables)),
107334
107384
  Fragment: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()).Fragment,
107335
107385
  components,
107336
107386
  passNode: true,
@@ -107345,7 +107395,7 @@ function createTocComponent(tocHast) {
107345
107395
  components: { p: (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default()).Fragment },
107346
107396
  });
107347
107397
  const tocReactElement = tocProcessor.stringify(tocHast);
107348
- const TocComponent = () => tocReactElement ? (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null, tocReactElement)) : null;
107398
+ const TocComponent = () => tocReactElement ? external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement(components_TableOfContents, null, tocReactElement) : null;
107349
107399
  TocComponent.displayName = 'Toc';
107350
107400
  return TocComponent;
107351
107401
  }
@@ -107394,7 +107444,7 @@ const renderMdxish = (tree, opts = {}) => {
107394
107444
  Object.entries(localScope).forEach(([name, value]) => {
107395
107445
  componentsForRehype[name] = value;
107396
107446
  });
107397
- const processor = createRehypeReactProcessor(componentsForRehype);
107447
+ const processor = createRehypeReactProcessor(componentsForRehype, variables);
107398
107448
  const content = processor.stringify(tree);
107399
107449
  const tocHast = headings.length > 0 ? tocToHast(headings, variables) : null;
107400
107450
  return buildRMDXModule(content, headings, tocHast, { ...contextOpts, variables });
@@ -107450,24 +107500,6 @@ function runSync(code, options) {
107450
107500
  // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
107451
107501
  var jsx_runtime = __webpack_require__(2467);
107452
107502
  var jsx_runtime_namespaceObject = /*#__PURE__*/__webpack_require__.t(jsx_runtime, 2);
107453
- ;// ./utils/user.ts
107454
- const User = (variables) => {
107455
- const { user = {}, defaults = [] } = variables || {};
107456
- return new Proxy(user, {
107457
- get(target, attribute) {
107458
- if (typeof attribute === 'symbol') {
107459
- return '';
107460
- }
107461
- if (attribute in target) {
107462
- return target[attribute];
107463
- }
107464
- const def = defaults.find((d) => d.name === attribute);
107465
- return def ? def.default : attribute.toUpperCase();
107466
- },
107467
- });
107468
- };
107469
- /* harmony default export */ const user = (User);
107470
-
107471
107503
  ;// ./lib/run.tsx
107472
107504
 
107473
107505
 
@@ -107712,7 +107744,7 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
107712
107744
 
107713
107745
 
107714
107746
 
107715
- const utils = {
107747
+ const index_utils = {
107716
107748
  get options() {
107717
107749
  return { ...options };
107718
107750
  },