mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Allow adding a comment to an individual HTML/OPF/NCX file to exclude it from being checked when running the spell check tool
This commit is contained in:
parent
4142b93443
commit
988b7d97f2
@ -678,6 +678,14 @@ common in your book and to run a simple search and replace on individual words.
|
||||
check tool. If you do not do this and continue to use the Spell check tool,
|
||||
you could lose the changes you have made in the editor.
|
||||
|
||||
.. note::
|
||||
To exclude an individual file from being spell checked when running the
|
||||
spell check tool, you can add the following comment just under the first
|
||||
opening tag in the file::
|
||||
|
||||
<!-- calibre-no-spell-check -->
|
||||
|
||||
|
||||
Adding new dictionaries
|
||||
###########################
|
||||
|
||||
|
@ -275,6 +275,14 @@ def get_checkable_file_names(container):
|
||||
return file_names, ncx_toc
|
||||
|
||||
|
||||
def root_is_excluded_from_spell_check(root):
|
||||
for child in root:
|
||||
q = (getattr(child, 'text', '') or '').strip().lower()
|
||||
if q == 'calibre-no-spell-check':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_all_words(container, book_locale, get_word_count=False):
|
||||
words = defaultdict(list)
|
||||
words[None] = 0
|
||||
@ -283,6 +291,8 @@ def get_all_words(container, book_locale, get_word_count=False):
|
||||
if not container.exists(file_name):
|
||||
continue
|
||||
root = container.parsed(file_name)
|
||||
if root_is_excluded_from_spell_check(root):
|
||||
continue
|
||||
if file_name == container.opf_name:
|
||||
read_words_from_opf(root, words, file_name, book_locale)
|
||||
elif file_name == ncx_toc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user