# Fumadocs Core (the core library of Fumadocs): Remark LLMs
URL: /docs/headless/mdx/remark-llms
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/mdx/remark-llms.mdx

Export the Markdown of your documents for LLMs.

The `remarkLLMs` plugin exports the Markdown of a document as `_markdown`, for LLMs. It keeps the Markdown you wrote. See [Stringification](/docs/headless/mdx/stringification) for how it's generated.

```mdx tab="Input"
import { Callout } from 'fumadocs-ui/components/callout';

## Getting Started

<Callout>Hello **world**.</Callout>
```

```md tab="Output"
## Getting Started [#getting-started]

<Callout>Hello **world**.</Callout>
```

ESM is removed, headings get their IDs (see `headingIds`), and included content is expanded with Fumadocs MDX.

## Usage [#usage]

`remarkLLMs` is a remark plugin. Enable it in Fumadocs MDX with `includeProcessedMarkdown`, on both unified and Sätteri:

```ts title="source.config.ts"
import { defineDocs } from 'fumadocs-mdx/config';

export const docs = defineDocs({
  docs: {
    postprocess: {
      // `true`, or the options of `remarkLLMs`
      includeProcessedMarkdown: true,
    },
  },
});
```

Read it from your pages with `getText('processed')`, which renders the Markdown with the page props:

```ts
const markdown = await page.data.getText('processed');
```

## Images [#images]

Images beside your pages, imported by [Remark Image](/docs/headless/mdx/remark-image), get the URLs your bundler serves them at:

```md tab="Input"
![How a calculation flows](./flow.png)
```

```md tab="Output"
![How a calculation flows](/assets/flow-Dxg6sAyC.png)
```

Images in the public directory keep their address. Vite inlines images smaller than [`build.assetsInlineLimit`](https://vite.dev/config/build-options#build-assetsinlinelimit) as `data:` URLs.

## Output [#output]

The `output` option sets the form of `_markdown`:

- `function`: `_markdown` is a component, which you render with [`renderToMarkdown()`](/docs/headless/utils/markdown). The Markdown is generated with the page props: content inside a [`<show>`](/docs/next/markdown#show) that isn't rendered is left out, expressions are replaced by their values, and JSX elements by their [Markdown form](#jsx-elements).
- `string`: `_markdown` is a string. Expressions and JSX elements are kept as source text, and a document with `<show>` fails to compile.

The default is `function` in Fumadocs MDX and `@fumadocs/astro`, and `string` elsewhere. A custom content source gets `function` with [runtime outputs](/docs/headless/source-api/source#runtime-outputs).

## JSX Elements [#jsx-elements]

With [`output: 'function'`](#output), a component is looked up like in MDX: first in the imports and declarations of the file, then in the MDX components of the [page props](/docs/headless/source-api#custom-props). Pass MDX components to a page with `getPage()`:

```ts
const page = source.getPage(slugs, { props: { components } });
```

A component defines its Markdown form with [`asMarkdown()`](/docs/headless/utils/markdown#asmarkdown). A component without one is kept as JSX. To remove elements, or replace them with their children, use `filterElement` (unavailable on Sätteri).

### Placeholders [#placeholders]

To render JSX elements yourself, list them as placeholders:

```ts
import type { LLMsOptions } from 'fumadocs-core/mdx-plugins/remark-llms';

const llmsOptions: LLMsOptions = {
  mdxAsPlaceholder: ['Callout'],
};
```

Then render them, from runtime data if needed:

```ts
import { renderPlaceholder } from 'fumadocs-core/mdx-plugins/remark-llms.runtime';

const markdown = await renderPlaceholder(await page.data.getText('processed'), {
  // `children` is the Markdown of its content
  Callout: ({ attributes, children }) => `> **${attributes.title}**\n>\n> ${children}`,
});
```

On Sätteri, `mdxAsPlaceholder` is unavailable.

## Options [#options]

| Prop                | Type                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `as?`               | `string \| undefined`                                        | export name for output Markdown. Default: `_markdown`                                                                                                                                                                                                                                                                                                                                                                                                       |
| `headingIds?`       | `boolean \| undefined`                                       | Explicit heading IDs in output. Default: `true`                                                                                                                                                                                                                                                                                                                                                                                                             |
| `filterElement?`    | `((node: Nodes) => boolean \| 'children-only') \| undefined` | Filter the elements to be included in the output: - `true`: include element & its children. - `children-only`: exclude element but keep its children. - `false`: exclude element & its children. ESM nodes are always excluded.                                                                                                                                                                                                                             |
| `mdxAsPlaceholder?` | `string[] \| undefined`                                      | Tag names of MDX components to be output as placeholders, render them with `renderPlaceholder()`.                                                                                                                                                                                                                                                                                                                                                           |
| `output?`           | `"function" \| "string" \| undefined`                        | Form of the export: - `string`: the output Markdown, authored expressions keep their source. - `function`: a component, render it with `renderToMarkdown` from `fumadocs-core/server`: JSX elements are kept as JSX, receiving their original props and resolving like in the content, a component can call `asMarkdown()` to define its own Markdown form. Default: `` `function` for a content source that renders pages for props, otherwise `string` `` |