Scripts2026年4月12日·1 分钟阅读

mdBook — Create Books from Markdown Like Gitbook in Rust

mdBook creates online books from Markdown files, similar to Gitbook but implemented in Rust. Used for the official Rust Book, Cargo Book, Tokio Tutorial, and many open-source documentation sites. Fast builds and a clean default theme.

SC
Script Depot · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

cargo install mdbook
mdbook init my-book
cd my-book
mdbook serve                                # Dev server at :3000
mdbook build                                # Build to book/

Directory structure:

my-book/
├── book.toml
└── src/
    ├── SUMMARY.md
    ├── chapter_1.md
    └── chapter_2/
        ├── section_1.md
        └── section_2.md

src/SUMMARY.md:

# Summary

- [Introduction](./chapter_1.md)
- [Getting Started](./chapter_2/section_1.md)
  - [Installation](./chapter_2/section_2.md)
介绍

mdBook is a command-line tool and Rust library to create online books from Markdown files. Similar to Gitbook but implemented in Rust — fast, single binary, no Node.js required. Used for the official Rust Book, Cargo Book, Tokio Tutorial, Bevy Book, and many Rust ecosystem docs.

What mdBook Does

  • Markdown to HTML — clean default theme
  • SUMMARY.md — table of contents as navigation
  • Search — full-text search built in
  • Syntax highlighting — for code blocks
  • Preprocessors — custom Markdown transforms
  • Renderers — HTML (default), PDF, EPUB via plugins
  • Themes — customizable CSS
  • Link checking — validate internal links
  • Includes — embed file contents with {{#include}}
  • Rust code testingmdbook test runs Rust code examples

Comparison

Tool Language Speed Node.js
mdBook Rust Fast No
Gitbook JS Medium Yes
Docusaurus JS Medium Yes
VitePress JS Fast Yes
Sphinx Python Medium No

常见问题 FAQ

Q: 和 VitePress 比? A: mdBook 零依赖(单 Rust 二进制),VitePress 需要 Node.js 但支持 Vue 组件和更丰富的自定义。纯文档选 mdBook,交互式文档选 VitePress。

来源与致谢 Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产