For AI agents: the complete documentation index is available at https://rspress.rs/llms.txt, the full documentation bundle is available at https://rspress.rs/llms-full.txt, and this page is available as Markdown at https://rspress.rs/api/config/config-markdown.md.
close
  • English
  • Markdown config

    Use markdown to extend Markdown and MDX syntax, configure code highlighting, check links and images, and register global MDX components.

    markdown.remarkPlugins

    • Type: Array
    • Default: []

    Configures remark plugins. For example:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        remarkPlugins: [
          [
            require('remark-autolink-headings'),
            {
              behavior: 'wrap',
            },
          ],
        ],
      },
    });

    markdown.rehypePlugins

    • Type: Array
    • Default: []

    Configures rehype plugins. For example:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        rehypePlugins: [
          [
            require('rehype-autolink-headings'),
            {
              behavior: 'wrap',
            },
          ],
        ],
      },
    });

    markdown.shiki

    • Type: import('@shikijs/rehype').RehypeShikiOptions
    • Default:
    const cssVariablesTheme = createCssVariablesTheme({
      name: 'css-variables',
      variablePrefix: '--shiki-',
      variableDefaults: {},
      fontStyle: true,
    });
    const shikiOptions = {
      theme: cssVariablesTheme,
      defaultLanguage: 'txt',
      lazy: true,
      langs: ['tsx', 'ts', 'js'],
      addLanguageClass: true,
    };

    Configure Shiki-related options. For details, see RehypeShikiOptions.

    markdown.shiki.transformers

    • Type: import('shiki').ShikiTransformer[]
    • Default:
    import {
      transformerNotationDiff,
      transformerNotationErrorLevel,
      transformerNotationFocus,
      transformerNotationHighlight,
      transformerNotationWordHighlight,
      transformerRemoveNotationEscape,
    } from '@shikijs/transformers';
    
    const transformers = [
      transformerNotationHighlight(),
      transformerNotationWordHighlight(),
      transformerNotationDiff(),
      transformerNotationFocus(),
      transformerNotationErrorLevel(),
      transformerRemoveNotationEscape(),
    ];

    These defaults also apply to CodeBlockRuntime. Escape annotations as [\!code ...] to display them literally.

    Custom transformers run before the default notation transformers. A custom transformer with the same name replaces the corresponding default; other defaults are preserved. Setting transformers: [] keeps the defaults enabled.

    Import transformers directly from @rspress/core/shiki-transformers without installing @shikijs/transformers separately. For example, add transformerMetaWordHighlight to highlight words using /word/ in code block meta attributes:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    import { transformerMetaWordHighlight } from '@rspress/core/shiki-transformers';
    
    export default defineConfig({
      markdown: {
        shiki: {
          transformers: [transformerMetaWordHighlight()],
        },
      },
    });
    ```ts /message/
    const message = 'Hello, Rspress!';
    console.log(message);
    ```

    See Shiki transformers for notation examples and more transformers.

    • Type:
    export type RemarkLinkOptions = {
      checkDeadLinks?:
        boolean | { excludes: string[] | ((url: string) => boolean) };
      checkAnchors?: boolean | { excludes: string[] | ((url: string) => boolean) };
      autoPrefix?: boolean;
    };
    • Default: { checkDeadLinks: true, checkAnchors: true, autoPrefix: true }

    Configure link-related options.

    • Type: boolean | { excludes: string[] | ((url: string) => boolean) }
    • Default: true

    When enabled, Rspress checks document links against the conventional routes. If a link is not accessible, the build fails.

    If a link is reported incorrectly, ignore it with excludes:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        link: {
          checkDeadLinks: {
            excludes: ['/guide/getting-started', '/llms.txt'],
          },
        },
      },
    });

    markdown.link.checkAnchors

    • Type: boolean | { excludes: string[] | ((url: string) => boolean) }
    • Default: true (false before v2.1.0)

    After enabling this configuration, Rspress will check whether internal link anchors exist in the target Markdown or MDX page. It checks same-page anchors, relative links, and absolute links, but skips external URL anchors.

    Set this option to false to disable anchor checking.

    If an anchor is reported incorrectly, ignore it with excludes:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        link: {
          checkAnchors: {
            excludes: ['/guide/getting-started#custom-anchor'],
          },
        },
      },
    });

    markdown.link.autoPrefix

    • Type: boolean
    • Default: true

    When enabled, Rspress automatically adds link prefixes based on the conventional routes for i18n and multi-version docs.

    If a user writes a link [](/guide/getting-started) in docs/zh/guide/index.md, Rspress will automatically convert it to [](/zh/guide/getting-started).

    markdown.image

    • Type:
    export type RemarkImageOptions = {
      checkDeadImages?:
        boolean | { excludes: string[] | ((url: string) => boolean) };
    };
    • Default: { checkDeadImages: true }

    Configure image-related options.

    markdown.image.checkDeadImages

    • Type: boolean | { excludes: string[] | ((url: string) => boolean) }
    • Default: true

    When enabled, Rspress checks local images in documents. If an image references a file that does not exist, the build fails.

    For relative image paths (e.g., ./image.png), the file is resolved relative to the current document. For absolute image paths (e.g., /image.png), the file is resolved from the public directory.

    If an image is reported incorrectly, ignore it with excludes:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        image: {
          checkDeadImages: {
            excludes: ['/generated-diagram.png'],
          },
        },
      },
    });

    markdown.showLineNumbers

    • Type: boolean
    • Default: false

    Controls whether code blocks show line numbers.

    When enabled globally, you can use lineNumbers=false in the code block meta to disable line numbers for a specific block. Conversely, when disabled globally, you can use lineNumbers or lineNumbers=true to enable line numbers for a specific block. See Show code line numbers for details.

    markdown.defaultWrapCode

    • Type: boolean
    • Default: false

    Controls whether long lines in code blocks wrap.

    When enabled globally, you can use wrapCode=false in the code block meta to disable wrapping for a specific block. Conversely, when disabled globally, you can use wrapCode or wrapCode=true to enable wrapping for a specific block. See Wrap code for details.

    markdown.defaultCodeOverflow

    • Type: { height?: number; behavior?: 'fold' | 'scroll' }
    • Default: undefined

    By default, Rspress code blocks are fully expanded with no overflow behavior. You can use meta attributes like ```tsx fold to control overflow for individual code blocks. This config sets the global default overflow behavior, which is automatically applied when code blocks exceed the specified height.

    • height: Height threshold in pixels. When not set, no overflow behavior is applied.
    • behavior: How to handle code blocks exceeding the height.
      • Default: 'scroll'
      • 'scroll': Fixed height with vertical scrollbar.
      • 'fold': Collapsible with an expand/collapse button.
    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        defaultCodeOverflow: {
          height: 400,
          behavior: 'fold',
        },
      },
    });

    Individual code blocks can override the default using height or fold meta attributes. See Code block height for details.

    markdown.crossCompilerCache

    • Type: boolean
    • Default: true

    Whether to enable cross-compiler cache for MDX compilation during rspress build. When enabled, Rspress will cache MDX parsing results across multiple compilers (web and node), which can speed up the production build process by approximately 10%.

    This option only takes effect in production builds and is inspired by Docusaurus.

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        crossCompilerCache: true,
      },
    });

    markdown.globalComponents

    • Type: string[]
    • Default: []

    Registers components globally so they are available in every MDX file without import statements. For example:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    import path from 'path';
    
    export default defineConfig({
      markdown: {
        globalComponents: [path.join(__dirname, 'src/src/components/Alert.tsx')],
      },
    });

    Then you can use the Alert component in any MDX file:

    test.mdx
    <Alert type="info">This is an info alert</Alert>

    markdown.extractDescription

    • Type: boolean
    • Default: true

    Whether to automatically extract the description from the markdown content. When enabled, Rspress extracts the first contentful paragraph below the h1 heading as the page description. If description is specified in frontmatter, it takes priority and automatic extraction is skipped.

    The extracted description is used for <meta name="description"> and Open Graph <meta property="og:description"> tags. See Custom Head - How description is determined for details.

    markdown.cjkFriendlyEmphasis

    • Type: boolean
    • Default: true

    Allows bold, italic, and strikethrough markers to touch CJK characters even when there is punctuation just inside the markers.

    **注意!**请先保存文件。

    With this option enabled, “注意!” appears in bold. When disabled, the asterisks are displayed as text due to a CommonMark limitation. See markdown-cjk-friendly for details.

    To disable:

    rspress.config.ts
    import { defineConfig } from '@rspress/core';
    
    export default defineConfig({
      markdown: {
        cjkFriendlyEmphasis: false,
      },
    });