Contributing to Lunr Languages
July 31, 2022 ยท View on GitHub
I found a bug
Thanks! Go to the Issues section and open a new issue. Please try to provide a detailed example describing the expected and actual outcome.
I found a bug and have a fix for it
Even better! Open a Pull request. Make sure you include everything needed in the pull request (check below)
I want to add a new language
Wonderful! Here are the changes you need to do, then Open a Pull request. Make sure you include everything needed in the pull request (check below)
- except Japanese, all the
lunr.<language>.jsfiles are built frombuild/lunr.template- If
lunr.templatefits your needs in terms of code/template, go tobuild/build.jsand add your language- You need a stemmer file
- You need a stop words file
- If
lunr.templatedoes not fit your needs (for example for non-latin characters), just copy anylunr.<language>.jsfile and start modifying
- If
- you must also test your new language
- go to
test/testdataand create a new file, then link it toVersionsAndLanguagesTest.js - make sure you cover many testcases (wildcard, stemming)
- your tests will automatically be run on all the Lunr versions
- go to
- add the new language to
README.md - re-build the files (check section below)
- open a Pull request. Make sure you include everything needed in the pull request (check below)
Pull request check-list
- Describe in detail what you did and why you did it
- Add tests. The more the better
- with at least 1 scenario in case of a bug-fix and 4 scenarios in case of a new language
- Don't open a Pull request for more unrelated topics. (eg a bug-fix, a new language, and few changes to stemming for existing languages in a single pull request)
Building your own files
The lunr.<locale>.js files are the result of a build process that concatenates a stemmer and a stop word list and add functionality to become lunr.js-compatible.
Should you decide to make mass-modifications (add stopwords, change stemming rules, reorganize the code) and build a new set of files, you should do follow these steps:
git clone --recursive https://github.com/MihaiValentin/lunr-languages.git(make sure you use the--recursiveflag to also clone the repos needed to buildlunr-languages)cd path/to/lunr-languagesnpm installto install the dependencies needed for building- change the
build/*.templatefiles - run
node build/build.jsto generate thelunr.<locale>.jsfiles (and the minified versions as well) and thelunr.stemmer.support.jsfile