@mintlify/common 1.0.1096 → 1.0.1098

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.
@@ -1,6 +1,7 @@
1
1
  import { rehypeCodeBlocks, rehypeDynamicTailwindCss, rehypeKeyboardSymbols, rehypeListItemText, rehypeMdxExtractEndpoint, rehypeMdxExtractExamples, rehypeParamFieldIds, rehypeRawComponents, rehypeTable, rehypeUnicodeIds, rehypeZoomImages, remarkExtractChangelogFilters, remarkExtractTableOfContents, remarkFileTree, remarkFrames, remarkComponentIds, remarkMdxInjectSnippets, remarkMdxRemoveUnusedVariables, remarkRemoveImports, remarkMdxExtractPanel, remarkResolveRelativeLinks, remarkVideo, remarkMdxClientComponentBoundaries, remarkExtractMultiView, remarkPrompt, remarkUnwrapInlineJsx, remarkUnwrapJsxHeadings, remarkMapExplicitAnchors, } from './plugins/index.js';
2
2
  import { remarkMdxRemoveUnknownJsx } from './plugins/remark/remarkMdxRemoveUnknownJsx/index.js';
3
3
  import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
4
+ import { remarkNoCopyLanguage } from './plugins/remark/remarkNoCopyLanguage.js';
4
5
  // avoid running extractors unnecessarily
5
6
  const rehypeExtractors = (mdxExtracts, data) => {
6
7
  if (!mdxExtracts)
@@ -28,6 +29,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], rehypePlugins = [], md
28
29
  remarkFileTree,
29
30
  remarkRemoveImports,
30
31
  remarkMermaid,
32
+ remarkNoCopyLanguage,
31
33
  remarkVideo,
32
34
  ...remarkPlugins,
33
35
  remarkMapExplicitAnchors,
@@ -10,6 +10,7 @@ export type Meta = {
10
10
  focus?: number[];
11
11
  theme?: string;
12
12
  twoslash?: boolean;
13
+ nocopy?: boolean;
13
14
  };
14
15
  export type MetaParserConfig = {
15
16
  [K in keyof Meta]: {
@@ -59,6 +59,10 @@ export const META_PARSER_CONFIG = {
59
59
  keys: ['twoslash'],
60
60
  parser: (metaOptions) => metaOptions.getBoolean('twoslash'),
61
61
  },
62
+ nocopy: {
63
+ keys: ['nocopy'],
64
+ parser: (metaOptions) => metaOptions.getBoolean('nocopy'),
65
+ },
62
66
  };
63
67
  export function parseMetaString(input) {
64
68
  const reservedKeys = Object.values(META_PARSER_CONFIG).flatMap((config) => config.keys);
@@ -7,6 +7,7 @@ export * from './remarkMdxRemoveUnusedVariables.js';
7
7
  export * from './remarkMdxRemoveUnknownJsx/index.js';
8
8
  export * from './remarkMdxClientComponentBoundaries.js';
9
9
  export * from './remarkMermaid.js';
10
+ export * from './remarkNoCopyLanguage.js';
10
11
  export * from './remarkMdxRemoveJs.js';
11
12
  export * from './remarkExtractChangelogFilters.js';
12
13
  export * from './remarkExpandContent.js';
@@ -7,6 +7,7 @@ export * from './remarkMdxRemoveUnusedVariables.js';
7
7
  export * from './remarkMdxRemoveUnknownJsx/index.js';
8
8
  export * from './remarkMdxClientComponentBoundaries.js';
9
9
  export * from './remarkMermaid.js';
10
+ export * from './remarkNoCopyLanguage.js';
10
11
  export * from './remarkMdxRemoveJs.js';
11
12
  export * from './remarkExtractChangelogFilters.js';
12
13
  export * from './remarkExpandContent.js';
@@ -0,0 +1,7 @@
1
+ import type { Root } from 'mdast';
2
+ /**
3
+ * Rewrites a bare ```nocopy fence to a plain-text block with the `nocopy` meta flag.
4
+ * Runs at the remark stage because shiki normalizes unknown languages to `text`
5
+ * before rehypeCodeBlocks sees the tree.
6
+ */
7
+ export declare const remarkNoCopyLanguage: () => (tree: Root) => void;
@@ -0,0 +1,20 @@
1
+ import { visit } from 'unist-util-visit';
2
+ const NO_COPY_LANGUAGE = 'nocopy';
3
+ const NO_COPY_META = /(^|\s)nocopy(\s|=|$)/;
4
+ /**
5
+ * Rewrites a bare ```nocopy fence to a plain-text block with the `nocopy` meta flag.
6
+ * Runs at the remark stage because shiki normalizes unknown languages to `text`
7
+ * before rehypeCodeBlocks sees the tree.
8
+ */
9
+ export const remarkNoCopyLanguage = () => {
10
+ return (tree) => {
11
+ visit(tree, 'code', (node) => {
12
+ if (node.lang !== NO_COPY_LANGUAGE)
13
+ return;
14
+ node.lang = 'text';
15
+ if (node.meta && NO_COPY_META.test(node.meta))
16
+ return;
17
+ node.meta = node.meta ? `${node.meta} nocopy` : 'nocopy';
18
+ });
19
+ };
20
+ };