Mkdocs-material: Fail to initialize searching index for languages other than 'en'

Created on 4 Aug 2020  路  9Comments  路  Source: squidfunk/mkdocs-material

__I checked that...__

  • [x] ... the documentation does not mention anything about my problem
  • [x] ... the problem doesn't occur with the default MkDocs template
  • [x] ... the problem is not in any of my customizations (CSS, JS, template)
  • [x] ... there are no open or closed issues that are related to my problem

Description

Version 5.5.1 and 5.5.2 fails to initialize search index with Japanese search mode but version 5.5.0 works well.

Expected behavior

5.5.0 works well.

git clone https://github.com/SI-Aizu/documentation.git
cd ./documentation
git checkout cd36072
docker-compose up

Open http://0.0.0.0:8888/, search with a Japanese word or an English word, it works well.

$ docker-compose run --rm --entrypoint=bash mkdocs
$ python --version
Python 3.8.5
$ mkdocs --version
mkdocs, version 1.1.2 from /usr/local/lib/python3.8/site-packages/mkdocs (Python 3.8)
$ pip show mkdocs-material | grep -E ^Version
Version: 5.5.0

Actual behavior

In 5.5.1 and 5.5.2, it shows only the message Initializing search and I cannot search with any word (any language). My browser console (Google Chrome) put the following error.

git clone https://github.com/SI-Aizu/documentation.git
cd ./documentation
git checkout a654e3b
docker-compose up

Screen Shot 2020-08-04 at 17 33 13

Uncaught TypeError: Cannot set property 'stemmerSupport' of undefined    index.ts:63
    at lunr.stemmer.support.min.js:1
    at lunr.stemmer.support.min.js:1
    at lunr.stemmer.support.min.js:1
    at index.ts:63
    at a (index.ts:85)
    at index.ts:109

Screen Shot 2020-08-04 at 17 20 11

$ docker-compose run --rm --entrypoint=bash mkdocs
$ python --version
Python 3.8.5
$ mkdocs --version
mkdocs, version 1.1.2 from /usr/local/lib/python3.8/site-packages/mkdocs (Python 3.8)
$ pip show mkdocs-material | grep -E ^Version
Version: 5.5.1

Steps to reproduce the bug

I already wrote about this above.

Package versions

I already wrote about this above.

Project configuration

I am using the same configuration between the 3 versions.

# Project information
site_name: 'SI-Aizu Documentation'
site_description: 'SI-Aizu Documentation'
site_author: 'SI-Aizu'
site_url: 'https://si-aizu.github.io/documentation'

# Copyright
copyright: '© 2020 SI-Aizu'

# Repository
repo_name: 'GitHub'
repo_url: 'https://github.com/SI-Aizu/documentation'
edit_uri: 'https://github.com/SI-Aizu/documentation/edit/main/docs'

# Configuration
docs_dir: 'docs'
theme:
  name: 'material'
  language: 'ja'
  shortcuts:
    help: 191    # ?
    next: 78     # n
    previous: 80 # p
    search: 83   # s
  palette:
    primary: indigo
    accent: orange
  # features:
  #   - tabs
  #font:
    #text: 'Ubuntu'
    #code: 'Ubuntu Mono'
  #icon:
    #logo: 'images/logo.svg'
  #favicon: 'assets/images/favicon.ico'

# Extensions
markdown_extensions:
  - admonition
  - codehilite
  - footnotes
  - mdx_math:
      enable_dollar_delimiter: true
  - toc:
      permalink: true
      separator: '_'

plugins:
  - search:
      separator: '[\s\-\.]+'
      lang:
        - ja

# Customization
extra_javascript:
  - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-MML-AM_CHTML'
extra_css:
  - 'assets/css/custom.css'
extra:
  # manifest: 'manifest.json'
  social:
    - icon: 'fontawesome/brands/github-alt'
      link: 'https://github.com/SI-Aizu/documentation'

System information

  • OS: macOS Mojave 10.14.6
  • Browser:

    • Google Chrome Version 84.0.4147.105 (Official Build) (64-bit)

    • Microsoft Edge Version 84.0.522.52 (Official build) (64-bit)

bug

Most helpful comment

Released as part of 5.5.3.

All 9 comments

Thanks for reporting - it's actually related to all other languages, I'll look into it asap.

Fixed in 13412008.

The problem was related to a change in bundling. With 5.5.1, we switched from expose-loader to the ProvidePlugin, which is generally a more natural fit, as we only want to prepend lunr to the search worker output. The problem is, that the minifier will now eradicate the global.lunr assignment, removing it from the global scope, which triggered a cascade of errors.

The referenced commit switches back to expose-loader (which was updated to 1.0.0).

Released as part of 5.5.3.

This was fixed in 5.5.3! Thank you for the quick fix.

In 6.0.1, if you specify 'ja', it remains "Initializing search".

I can't reproduce this, Japanese search works on a clean installation for me:

screenshot-0-0-0-0-8000-1601361624363

Contents of mkdocs.yml:

site_name: My Docs
theme:
  name: material
  language: ja

Thanks for the confirmation.
I have created a reproduction environment.

https://github.com/ryo1988/mkdocsTest

Clone it and Run it.

  • Run.4.6.3.bat OK
    image

  • Run.6.0.1.bat NG
    image

ENVIRONMENT:

Thanks for providing the reproduction. However, it's exactly the same as the one I posted in my last comment and I'm yet unable to reproduce the error you're seeing.

When I tried 5.0.0, it was not successful.
I changed the "HKEY_CLASSES_ROOT.js\Content Type" in the registry from "text/plain" to "text/javascript" and it became OK.
Do I have to set the "HKEY_CLASSES_ROOT.js\Content Type" in the registry to "text/javascript"?

Was this page helpful?
0 / 5 - 0 ratings