rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.84k stars 1.62k forks source link

Add non-English search support #2392

Open Sunshine40 opened 4 months ago

Sunshine40 commented 4 months ago

This PR implements the search-non-english feature, inspired by #1496.

Configure book.language like this:

[book]
author = ["The Rust Project Developers", "Pure White."]
title = "Rust 秘典(死灵书)"
description = "Unsafe Rust 的黑魔法指南"
language = "zh-Hans"

and with search-non-english feature enabled, mdBook would choose the search indexing implementation based on the language config.

You can use this repo to try it out, or preview the search functionality online!

language config should follow lang - HTML: HyperText Markup Language | MDN > Language tag syntax.

Currently supported languages can be found in the languages section of elasticlunr-rs's feature flag list

~Note: teaser is still buggy (at least for Chinese).~