From bb36ff93d773fc8d35878aab18a18117ee3b99c5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 20 Mar 2016 17:30:38 +0530 Subject: [PATCH] Edit Book: Check Book: Add a check for empty links --- src/calibre/ebooks/oeb/polish/check/links.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/check/links.py b/src/calibre/ebooks/oeb/polish/check/links.py index 130f504519..821581dd47 100644 --- a/src/calibre/ebooks/oeb/polish/check/links.py +++ b/src/calibre/ebooks/oeb/polish/check/links.py @@ -90,6 +90,10 @@ class LocalLink(BadLink): ' book is read on any computer other than the one it was created on.' ' Either fix or remove the link.') +class EmptyLink(BadLink): + + HELP = _('This link is empty. This is almost always a mistake. Either fill in the link destination or remove the link tag.') + class UnreferencedResource(BadLink): HELP = _('This file is included in the book but not referred to by any document in the spine.' @@ -278,6 +282,8 @@ def check_links(container): for name, mt in container.mime_map.iteritems(): if mt in OEB_DOCS or mt in OEB_STYLES or mt in xml_types: for href, lnum, col in container.iterlinks(name): + if not href: + a(EmptyLink(_('The link is empty'), name, lnum, col)) try: tname = container.href_to_name(href, name) except ValueError: