コード例 #1
0
    def test_hyphenate_html(self):
        root = parse_html5('''
<p>beautiful, <span lang="sv"><!-- x -->tillata\n<span lang="en">Expand</span></span> "latitude!''',
                           line_numbers=False)
        add_soft_hyphens_to_html(root, hyphen_char='=')
        raw = etree.tostring(root, method='text', encoding='unicode')
        self.ae(raw, 'beau=ti=ful, tilla=ta\nEx=pand "lat=i=tude!')
コード例 #2
0
def add_soft_hyphens(container, report=None):
    from calibre.utils.hyphenation.hyphenate import add_soft_hyphens_to_html
    for name, mt in iteritems(container.mime_map):
        if mt not in OEB_DOCS:
            continue
        add_soft_hyphens_to_html(container.parsed(name), container.mi.language)
        container.dirty(name)
    if report is not None:
        report(_('Soft hyphens added'))