diff --git a/src/calibre/ebooks/conversion/utils.py b/src/calibre/ebooks/conversion/utils.py index 1546644f95..7488df4609 100644 --- a/src/calibre/ebooks/conversion/utils.py +++ b/src/calibre/ebooks/conversion/utils.py @@ -156,17 +156,17 @@ class HeuristicProcessor(object): ] ITALICIZE_STYLE_PATS = [ - r'(?msu)(?<=[\s>])_(?P[^_]+)_', - r'(?msu)(?<=[\s>])/(?P[^/\*>]+)/', - r'(?msu)(?<=[\s>])~~(?P[^~]+)~~', - r'(?msu)(?<=[\s>])\*(?P[^\*]+)\*', - r'(?msu)(?<=[\s>])~(?P[^~]+)~', - r'(?msu)(?<=[\s>])_/(?P[^/_]+)/_', - r'(?msu)(?<=[\s>])_\*(?P[^\*_]+)\*_', - r'(?msu)(?<=[\s>])\*/(?P[^/\*]+)/\*', - r'(?msu)(?<=[\s>])_\*/(?P[^\*_]+)/\*_', - r'(?msu)(?<=[\s>])/:(?P[^:/]+):/', - r'(?msu)(?<=[\s>])\|:(?P[^:\|]+):\|', + ur'(?msu)(?<=[\s>"“\'‘])_(?P[^_]+)_', + ur'(?msu)(?<=[\s>"“\'‘])/(?P[^/\*>]+)/', + ur'(?msu)(?<=[\s>"“\'‘])~~(?P[^~]+)~~', + ur'(?msu)(?<=[\s>"“\'‘])\*(?P[^\*]+)\*', + ur'(?msu)(?<=[\s>"“\'‘])~(?P[^~]+)~', + ur'(?msu)(?<=[\s>"“\'‘])_/(?P[^/_]+)/_', + ur'(?msu)(?<=[\s>"“\'‘])_\*(?P[^\*_]+)\*_', + ur'(?msu)(?<=[\s>"“\'‘])\*/(?P[^/\*]+)/\*', + ur'(?msu)(?<=[\s>"“\'‘])_\*/(?P[^\*_]+)/\*_', + ur'(?msu)(?<=[\s>"“\'‘])/:(?P[^:/]+):/', + ur'(?msu)(?<=[\s>"“\'‘])\|:(?P[^:\|]+):\|', ] for word in ITALICIZE_WORDS: @@ -518,13 +518,13 @@ class HeuristicProcessor(object): if re.findall('(<|>)', replacement_break): if re.match('^\d+).*', '\g', replacement_break)) - replacement_break = re.sub('(?i)(width=\d+\%?|width:\s*\d+(\%|px|pt|em)?;?)', '', replacement_break) - divpercent = (100 - width) / 2 - hr_open = re.sub('45', str(divpercent), hr_open) - scene_break = hr_open+replacement_break+'' + width = int(re.sub('.*?width(:|=)(?P\d+).*', '\g', replacement_break)) + replacement_break = re.sub('(?i)(width=\d+\%?|width:\s*\d+(\%|px|pt|em)?;?)', '', replacement_break) + divpercent = (100 - width) / 2 + hr_open = re.sub('45', str(divpercent), hr_open) + scene_break = hr_open+replacement_break+'' else: - scene_break = hr_open+'
' + scene_break = hr_open+'
' elif re.match('^' else: @@ -584,10 +584,10 @@ class HeuristicProcessor(object): #print "styles for this line are: "+str(styles) split_styles = [] for style in styles: - #print "style is: "+str(style) - newstyle = style.split(':') - #print "newstyle is: "+str(newstyle) - split_styles.append(newstyle) + #print "style is: "+str(style) + newstyle = style.split(':') + #print "newstyle is: "+str(newstyle) + split_styles.append(newstyle) styles = split_styles for style, setting in styles: if style == 'text-align' and setting != 'left': diff --git a/src/calibre/gui2/threaded_jobs.py b/src/calibre/gui2/threaded_jobs.py index ad295503a0..eb8667a713 100644 --- a/src/calibre/gui2/threaded_jobs.py +++ b/src/calibre/gui2/threaded_jobs.py @@ -112,7 +112,7 @@ class ThreadedJob(BaseJob): self.start_time = time.time() self.duration = 0.0001 else: - self.duration = time.time() - self.start_time() + self.duration = time.time() - self.start_time self.abort.set() self.log('Aborted job:', self.description)