sphinx-contrib / spelling

A spelling checker for Sphinx-based documentation
https://sphinxcontrib-spelling.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
82 stars 47 forks source link

Question - Confusion over spelling:word role #198

Closed grhm closed 1 year ago

grhm commented 1 year ago

The documentation at https://sphinxcontrib-spelling.readthedocs.io/en/latest/customize.html#private-dictionaries says:

The spelling:word role can be used to annotate individual words as being spelled correctly.

I'd read that to mean I can markup a single instance of a word as correctly spelled, but it would still be flagged as incorrect elsewhere. This is ideal for marking up some text as correct e.g. words in a quote taken verbatim from somewhere else, that we don't want to alter, don't want to be flagged a misspelt, but don't want to add the the dictionary and allow elsewhere in the document.

For example, I thought this would work in a project using en_GB:

I want to allow :spelling:word:`specialize` to *not* be flagged as misspelt in this sentence - which works.
But it should be flagged as misspelt in this sentence as "specialize" should be spelt "specialise" in British English.

However, it appears to use the spelling:word role to add to the wordlist for the entire document. The sphinx output says "Extending local dictionary for ". And the word is not flagged as misspelt as I had hoped.

Is that the intention? Is there any difference between the spelling:word role and the spelling:word-list directive?

Is there a way to ignore a single instance of a word?

The use cases I'm interested in for my current project are:

dhellmann commented 1 year ago

Yes, the current role adds the word to the list for the document. If you wanted to code up a different role to ignore a word one time (maybe spelling:ignore?), that seems like it would be a good addition. I'm not sure exactly how that could be made to work. Perhaps filtering the word out when tokenizing?