Skip to content

Commit ef7b03d

Browse files
Merge pull request #85 from armstrongttwalker-alt/docs/fix-cn-search
fix: patch stemWord method for Sphinx 9 search compatibility
2 parents be442e6 + 819f146 commit ef7b03d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,18 @@ def get_project(projects):
265265
# =====================================================================
266266

267267
# 1. Inject front-end fallback scripts early in HTML <head> for Chinese localization.
268-
# This bypasses the Sphinx 9+ 'ChineseStemmer is not defined' runtime crash.
268+
# This bypasses the Sphinx 9+ 'stemmer.stemWord is not a function' runtime crash.
269269
html_context = {}
270270
if docset == "zh":
271271
html_context["metatags"] = """
272272
<script>
273273
if (typeof Stemmer === 'undefined') {
274-
window.Stemmer = function() { return { stem: function(w){return w;} }; };
274+
window.Stemmer = function() {
275+
return {
276+
stem: function(w){ return w; },
277+
stemWord: function(w){ return w; }
278+
};
279+
};
275280
}
276281
if (typeof ChineseStemmer === 'undefined') {
277282
window.ChineseStemmer = window.Stemmer;

0 commit comments

Comments
 (0)