Skip to content

Commit d6db510

Browse files
committed
fix chinese words search
1 parent 519fc27 commit d6db510

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

3.x/zh_CN/conf.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import sys
1616
import os
17+
import jieba
1718

1819
#sys.path.insert(0, os.path.abspath('..'))
1920
import sphinx_rtd_theme
@@ -64,6 +65,15 @@
6465
'myst_parser'
6566
]
6667

68+
myst_enable_extensions = [
69+
"linkify", # 自动转换 URL 为链接
70+
# "replacements", # 支持文本替换
71+
# "smartquotes", # 美化引号
72+
# "strikethrough", # 支持删除线
73+
# "substitution", # 支持替换变量
74+
# "attrs_block", # 支持 Markdown 块级属性
75+
]
76+
6777
# Add any paths that contain templates here, relative to this directory.
6878
templates_path = ['../_templates']
6979

@@ -234,6 +244,23 @@
234244
#html_search_language = 'en'
235245
html_search_language = 'zh'
236246

247+
# def chinese_tokenizer(text):
248+
# return list(jieba.cut(text))
249+
250+
html_search_options = {
251+
'search_language': 'zh', # 指定中文
252+
'search_mode': 'full_text', # 全文搜索
253+
'additional_keywords': [
254+
'区块链',
255+
'智能合约',
256+
'共识算法',
257+
'分布式账本',
258+
'密码学',
259+
'非对称加密',
260+
'联盟链'
261+
]
262+
}
263+
237264
# A dictionary with options for the search language support, empty by default.
238265
# Now only 'ja' uses this config value
239266
#html_search_options = {'type': 'default'}

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ git-lfs
1313
Jinja2<3.1
1414
myst-parser == 0.13.0
1515
pyyaml
16-
16+
jieba
17+
linkify-it-py
18+
# markdown-it-py

0 commit comments

Comments
 (0)