From 7c3354caf9bb8fc85c0bd415dc6a8d4736615b11 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Apr 2014 21:09:22 +0530 Subject: [PATCH] Smarten punctuation: Fix a double quote preceded by a hyphen at the end of a sentence (before the start of the next tag) being converted into an opening quote instead of closing quote. Fixes #1286477 [Smarten punctuation uses wrong character at end of paragraph](https://bugs.launchpad.net/calibre/+bug/1286477) --- src/calibre/utils/smartypants.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/utils/smartypants.py b/src/calibre/utils/smartypants.py index 51079e4e47..1bc45b15e4 100644 --- a/src/calibre/utils/smartypants.py +++ b/src/calibre/utils/smartypants.py @@ -696,6 +696,10 @@ def educateQuotes(str): """ % (close_class,), re.VERBOSE) str = closing_double_quotes_regex.sub(r"""\1”""", str) + if str.endswith('-"'): + # A string that endswith -" is sometimes used for dialogue + str = str[:-1] + '”' + # Any remaining quotes should be opening ones. str = re.sub(r'"', r"""“""", str)