vkbo / novelWriter

novelWriter is an open source plain text editor designed for writing novels. It supports a minimal markdown-like syntax for formatting text. It is written with Python 3 (3.9+) and Qt 5 (5.15) for cross-platform support.
https://novelwriter.io
GNU General Public License v3.0
2.12k stars 111 forks source link

Spell check tool and adding dictionaries #982

Closed vkbo closed 12 months ago

vkbo commented 2 years ago

I would like to add a dialog tool for spell checking similar to what is used in office applications. It is useful for people who don't want automatic spell checking. Automatic checking can also be quite slow on large documents.

In addition, the enchant package that is used for spell checking only comes with English dictionaries on Windows. Since it uses the same dictionaries as Firefox, Libre Office and Free Office, among other tools, it should be easy enough to import them. A simple dialog could handle an import from downloaded files.

hunspell dictionaries must be added to a folder named hunspell under the path given by enchant.get_user_config_dir() from within novelWriter. That path should be C:\Users\<UserName>\AppData\Local\enchant on Windows.

In fact, users can easily add dictionaries there now. The *.dic and *.aff files from the following sources can all be used:

For the extensions, they just need to be unzipped.

vkbo commented 2 years ago

Note to self: use this source: https://github.com/vkbo/dictionaries

See also: Discussion #1066

tmarplatt commented 1 year ago

If not this, it would be great to simply use hotkeys to quickly browse through detected misspellings, i.e. jump the text cursor to the next detection. Additionally, a hotkey to add the word under the cursor to the project Word List.

vkbo commented 1 year ago

I've restructured spell checking already for the next release, 2.2, so it now saves spell check meta data together with the paragraph in the editor. It should definitely be possible to then create a hotkey to jump trough spell check errors. I also plan to add a show/hide details panel below the editor where I could add a list of spell check errors.

vkbo commented 12 months ago

In the end I implemented a dialog box that will accept spell checker dictionary files downloaded from Free Office or LibreOffice. They are just zip files, and the relevant Hunspell files are extracted and copied to the enchant folder.

My first implementation worked with automatic downloads from my forked repo from LibreOffice, but I was concerned the external dependency from within novelWriter would be hard to maintain. This one does not rely on any external source to be available and no data is downloaded directly by novelWriter.