@mui/internal-docs-infra 0.3.1-canary.2 → 0.3.1-canary.3

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.
@@ -41,6 +41,7 @@ function renderCode(hastChildren, renderHast, text) {
41
41
  export function Pre(_ref) {
42
42
  var children = _ref.children,
43
43
  className = _ref.className,
44
+ language = _ref.language,
44
45
  ref = _ref.ref,
45
46
  shouldHighlight = _ref.shouldHighlight,
46
47
  _ref$hydrateMargin = _ref.hydrateMargin,
@@ -162,6 +163,7 @@ export function Pre(_ref) {
162
163
  ref: bindIntersectionObserver,
163
164
  className: className,
164
165
  children: /*#__PURE__*/_jsx("code", {
166
+ className: language ? "language-".concat(language) : undefined,
165
167
  children: typeof children === 'string' ? children : frames
166
168
  })
167
169
  });
@@ -6,14 +6,32 @@ import { decompressSync, strFromU8 } from 'fflate';
6
6
  import { decode } from 'uint8-to-base64';
7
7
  import { useUrlHashState } from "../useUrlHashState/index.js";
8
8
  import { countLines } from "../pipeline/parseSource/addLineGutters.js";
9
+ import { getLanguageFromExtension } from "../pipeline/loaderUtils/getLanguageFromExtension.js";
9
10
  import { Pre } from "./Pre.js";
10
11
 
12
+ /**
13
+ * Gets the language from a filename by extracting its extension.
14
+ * @param fileName - The filename (e.g., 'index.tsx', 'styles.css')
15
+ * @returns The language name or undefined
16
+ */
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ function getLanguageFromFileName(fileName) {
19
+ if (!fileName) {
20
+ return undefined;
21
+ }
22
+ var lastDotIndex = fileName.lastIndexOf('.');
23
+ if (lastDotIndex === -1) {
24
+ return undefined;
25
+ }
26
+ var extension = fileName.substring(lastDotIndex);
27
+ return getLanguageFromExtension(extension);
28
+ }
29
+
11
30
  /**
12
31
  * Converts a string to kebab-case
13
32
  * @param str - The string to convert
14
33
  * @returns kebab-case string
15
34
  */
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
35
  export function toKebabCase(str) {
18
36
  return str
19
37
  // Insert a dash before any uppercase letter that follows a lowercase letter or digit
@@ -402,6 +420,7 @@ export function useFileNavigation(_ref) {
402
420
  }
403
421
  return /*#__PURE__*/_jsx(Pre, {
404
422
  className: preClassName,
423
+ language: selectedVariant.language,
405
424
  ref: preRef,
406
425
  shouldHighlight: shouldHighlight,
407
426
  children: selectedVariant.source
@@ -424,6 +443,7 @@ export function useFileNavigation(_ref) {
424
443
  }
425
444
  return /*#__PURE__*/_jsx(Pre, {
426
445
  className: preClassName,
446
+ language: getLanguageFromFileName(selectedFileNameInternal),
427
447
  ref: preRef,
428
448
  shouldHighlight: shouldHighlight,
429
449
  children: source
@@ -497,6 +517,7 @@ export function useFileNavigation(_ref) {
497
517
  slug: generateFileSlug(mainSlug, selectedVariant.fileName, selectedVariantKey),
498
518
  component: /*#__PURE__*/_jsx(Pre, {
499
519
  className: preClassName,
520
+ language: selectedVariant.language,
500
521
  ref: preRef,
501
522
  shouldHighlight: shouldHighlight,
502
523
  children: selectedVariant.source
@@ -509,10 +530,12 @@ export function useFileNavigation(_ref) {
509
530
  fileName = _ref3[0],
510
531
  fileData = _ref3[1];
511
532
  var source;
533
+ var language;
512
534
  if (typeof fileData === 'string') {
513
535
  source = fileData;
514
536
  } else if (fileData && _typeof(fileData) === 'object' && 'source' in fileData) {
515
537
  source = fileData.source;
538
+ language = fileData.language;
516
539
  } else {
517
540
  return; // Skip invalid entries
518
541
  }
@@ -524,6 +547,7 @@ export function useFileNavigation(_ref) {
524
547
  slug: generateFileSlug(mainSlug, fileName, selectedVariantKey),
525
548
  component: /*#__PURE__*/_jsx(Pre, {
526
549
  className: preClassName,
550
+ language: language != null ? language : getLanguageFromFileName(fileName),
527
551
  ref: preRef,
528
552
  shouldHighlight: shouldHighlight,
529
553
  children: source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.3.1-canary.2",
3
+ "version": "0.3.1-canary.3",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "bin": {
@@ -329,5 +329,5 @@
329
329
  },
330
330
  "./esm": null
331
331
  },
332
- "gitSha": "1ff097fa93dd7975b1282196feadba23916b2347"
332
+ "gitSha": "d451af44f7bc27fd589bdeda8f07395fa2037ad8"
333
333
  }