mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Check Book: Add a warning for links with the : character in them on windows
This commit is contained in:
parent
3f5f29377f
commit
415fb9c317
@ -14,7 +14,7 @@ from threading import Thread
|
|||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
from calibre import browser
|
from calibre import browser
|
||||||
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
|
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, urlunquote
|
||||||
from calibre.ebooks.oeb.polish.container import OEB_FONTS
|
from calibre.ebooks.oeb.polish.container import OEB_FONTS
|
||||||
from calibre.ebooks.oeb.polish.replace import remove_links_to
|
from calibre.ebooks.oeb.polish.replace import remove_links_to
|
||||||
from calibre.ebooks.oeb.polish.cover import get_raster_cover_name
|
from calibre.ebooks.oeb.polish.cover import get_raster_cover_name
|
||||||
@ -29,6 +29,12 @@ class BadLink(BaseError):
|
|||||||
level = WARN
|
level = WARN
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidCharInLink(BadLink):
|
||||||
|
|
||||||
|
HELP = _('Windows computers do not allow the : character in filenames. For maximum'
|
||||||
|
' compatibility it is best to not use these in filenames/links to files.')
|
||||||
|
|
||||||
|
|
||||||
class CaseMismatch(BadLink):
|
class CaseMismatch(BadLink):
|
||||||
|
|
||||||
def __init__(self, href, corrected_name, name, lnum, col):
|
def __init__(self, href, corrected_name, name, lnum, col):
|
||||||
@ -342,6 +348,8 @@ def check_links(container):
|
|||||||
a(FileLink(_('The link %s is a file:// URL') % fl(href), name, lnum, col))
|
a(FileLink(_('The link %s is a file:// URL') % fl(href), name, lnum, col))
|
||||||
elif purl.path and purl.path.startswith('/') and purl.scheme in {'', 'file'}:
|
elif purl.path and purl.path.startswith('/') and purl.scheme in {'', 'file'}:
|
||||||
a(LocalLink(_('The link %s points to a file outside the book') % fl(href), name, lnum, col))
|
a(LocalLink(_('The link %s points to a file outside the book') % fl(href), name, lnum, col))
|
||||||
|
elif purl.path and purl.scheme in {'', 'file'} and ':' in urlunquote(purl.path):
|
||||||
|
a(InvalidCharInLink(_('The link %s contains a : character, this will cause errors on windows computers') % fl(href), name, lnum, col))
|
||||||
|
|
||||||
spine_docs = {name for name, linear in container.spine_names}
|
spine_docs = {name for name, linear in container.spine_names}
|
||||||
spine_styles = {tname for name in spine_docs for tname in links_map[name] if container.mime_map.get(tname, None) in OEB_STYLES}
|
spine_styles = {tname for name in spine_docs for tname in links_map[name] if container.mime_map.get(tname, None) in OEB_STYLES}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user