From 24a344546edc0793254ccc13ecdc7c7309db51a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 14 Jul 2019 18:50:47 +0530 Subject: [PATCH] DRYer --- src/calibre/ebooks/pdf/html_writer.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/pdf/html_writer.py b/src/calibre/ebooks/pdf/html_writer.py index 0004c0903b..b68352041b 100644 --- a/src/calibre/ebooks/pdf/html_writer.py +++ b/src/calibre/ebooks/pdf/html_writer.py @@ -33,7 +33,7 @@ from calibre.gui2.webengine import secure_webengine from calibre.utils.logging import default_log from calibre.utils.podofo import get_podofo, set_metadata_implementation from calibre.utils.short_uuid import uuid4 -from polyglot.builtins import iteritems, range, unicode_type +from polyglot.builtins import iteritems, map, range, unicode_type from polyglot.urllib import urlparse OK, KILL_SIGNAL = range(0, 2) @@ -280,13 +280,13 @@ def add_anchors_markup(root, uuid, anchors): body = root[-1] div = body.makeelement(XHTML('div'), id=uuid, style='page-break-before: always') body.append(div) - for i, anchor in enumerate(anchors): + + def a(anchor): div.append(div.makeelement(XHTML('a'), href='#' + anchor)) div[-1].text = '\xa0' div[-1].tail = ' ' - div.append(div.makeelement(XHTML('a'), href='#' + uuid)) - div[-1].text = '\xa0' - div[-1].tail = ' ' + tuple(map(a, anchors)) + a(uuid) def add_all_links(container, margin_groups):