diff --git a/src/calibre/ebooks/html_entities.h b/src/calibre/ebooks/html_entities.h index 03f6d17520..073326ab4c 100644 --- a/src/calibre/ebooks/html_entities.h +++ b/src/calibre/ebooks/html_entities.h @@ -1,5 +1,5 @@ /* ANSI-C code produced by gperf version 3.1 */ -/* Command-line: gperf -t --readonly --includes */ +/* Command-line: gperf --struct-type --readonly --includes */ /* Computed positions: -k'1-7,10,12,$' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ diff --git a/src/calibre/ebooks/html_entities.py b/src/calibre/ebooks/html_entities.py index 0456d9ceaa..b1a9d969cb 100644 --- a/src/calibre/ebooks/html_entities.py +++ b/src/calibre/ebooks/html_entities.py @@ -2135,13 +2135,26 @@ html5_entities = { } +def find_tests(): + import unittest + class TestHTMLEntityReplacement(unittest.TestCase): + def test_html_entity_replacement(self): + from calibre_extensions.fast_html_entities import replace_entities + def t(inp, exp): + self.assertEqual(exp, replace_entities(inp), f'Failed for input: {inp!r}') + t('', '') + t('a', 'a') + + return unittest.defaultTestLoader.loadTestsFromTestCase(TestHTMLEntityReplacement) + + def generate_entity_lists(): import re from html import entities as e entities = {k.rstrip(';'): e.name2codepoint[k] for k in e.name2codepoint} entities.update({k.rstrip(';'): e.html5[k] for k in e.html5}) # common misspelled entity names - for k, v in {'apos': "'", 'squot': "'", 'hellips': entities['hellip']}.items(): + for k, v in {'squot': "'", 'hellips': entities['hellip']}.items(): if k not in entities: entities[k] = v lines = [] diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py index 71128c243e..699582961a 100644 --- a/src/calibre/utils/run_tests.py +++ b/src/calibre/utils/run_tests.py @@ -269,6 +269,8 @@ def find_tests(which_tests=None, exclude_tests=None): a(find_tests()) from calibre.gui2.viewer.annotations import find_tests a(find_tests()) + from calibre.ebooks.html_entities import find_tests + a(find_tests()) if ok('misc'): from calibre.ebooks.html.input import find_tests a(find_tests())