> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# configs

```ts
import { MEDIAWIKI_CONFIG } from "react-wikitext/configs";
import type { ParserConfig } from "react-wikitext/configs";
```

`/configs` 只包含站点配置常量与类型，不加载解析器或 React。配置在创建解析器时固定；之后修改原对象不会影响解析器。

## 常量

| 常量                 | 说明                                        |
| ------------------ | ----------------------------------------- |
| `MEDIAWIKI_CONFIG` | 默认配置，来源是 `wikiparser-node@1.48.1` 的站点配置快照 |

```ts
type ParserConfig = ConfigData & { excludes?: string[] };
```

字段来自上游 `wikiparser-node`。库不导出归一化函数或来源常量；最小配置不属于公共 API，需要时应从上游包读取并自行承担退化行为。

## 创建解析器

```ts
import { createWikiparser } from "react-wikitext/parse";
import { MEDIAWIKI_CONFIG } from "react-wikitext/configs";

const parser = createWikiparser({
  config: MEDIAWIKI_CONFIG,
  defaults: { pageName: "Example" },
});
```

- 配置在工厂创建时深拷贝并归一化：补齐 `excludes`、归一化 `doubleUnderscore`，并做最小结构校验。
- 非法配置抛 `WikitextParseError("INVALID_CONFIG")`。
- 更换配置需要创建新的解析器，避免每次解析隐式修改共享配置。
- `defaults` 是每次解析的默认选项，可以按调用覆盖；预算合并规则见[解析 `/parse`](/zh/api/parse.md)。

## 自定义站点配置

需要站点差异时，以 `MEDIAWIKI_CONFIG` 为基础复制并调整字段；这是唯一受支持的配置路径。不要依赖上游的最小配置作为公共选项：它会让 `<ref>`、`<gallery>` 与文件参数静默退化，库不为它提供兼容承诺。确实需要最小识别时，可以从 `wikiparser-node/config/minimum.json` 读取并自行转换为 `ParserConfig`，但要先确认这些退化可接受。

## 与预算的关系

站点配置不包含解析预算。源码长度、节点数与深度上限属于解析选项，按“单次解析 → 创建时 `defaults` → 共享默认值”合并；见[性能与预算](/zh/guide/performance.md)。

## 相关

- [解析 `/parse`](/zh/api/parse.md)：`createWikiparser` 与解析选项。
- [状态与兼容性](/zh/project/status.md)：固定的上游版本。
