E-book viewer: Fix sorting of bookmarks by position in book not working on windows and OS X. Fixes #1402152 [error when sorting bookmarks by position](https://bugs.launchpad.net/calibre/+bug/1402152)

This commit is contained in:
Kovid Goyal 2014-12-13 17:03:30 +05:30
parent cfbf573c1b
commit 8aaf03ef28

View File

@ -6,9 +6,11 @@ from __future__ import (unicode_literals, division, absolute_import,
__license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import regex
import regex, sys
from future_builtins import map, zip
is_narrow_build = sys.maxunicode < 0x10ffff
class Parser(object):
''' See epubcfi.ebnf for the specification that this parser tries to
@ -19,7 +21,10 @@ class Parser(object):
def __init__(self):
# All allowed unicode characters + escaped special characters
special_char = r'[\[\](),;=^]'
unescaped_char = '[[\t\n\r -\ud7ff\ue000-\ufffd\U00010000-\U0010ffff]--%s]' % special_char
if is_narrow_build:
unescaped_char = '[[\t\n\r -\ud7ff\ue000-\ufffd]--%s]' % special_char
else:
unescaped_char = '[[\t\n\r -\ud7ff\ue000-\ufffd\U00010000-\U0010ffff]--%s]' % special_char
escaped_char = r'\^' + special_char
chars = r'(?:%s|(?:%s))+' % (unescaped_char, escaped_char)
chars_no_space = chars.replace('0020', '0021')