From a1b7341d809e6ffa0ea51a9e5bca59f9566adca0 Mon Sep 17 00:00:00 2001 From: Lee Date: Wed, 23 May 2012 02:08:11 +0800 Subject: [PATCH 1/3] fix for smartypants getting screwed up by formatting tags within a sentence. --- src/calibre/utils/smartypants.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/calibre/utils/smartypants.py b/src/calibre/utils/smartypants.py index fa3119bf53..c29b258722 100644 --- a/src/calibre/utils/smartypants.py +++ b/src/calibre/utils/smartypants.py @@ -601,10 +601,6 @@ def educateQuotes(str): # Special case for Quotes at end of line with a preceeding space (may change just to end of line) str = re.sub(r"""(?<=\s)"$""", r"""”""", str) str = re.sub(r"""(?<=\s)'$""", r"""’""", str) - - # Special case for Quotes at beginning of line with a space - multiparagraph quoted text: - str = re.sub(r"""^"(?=\s)""", r"""“""", str) - str = re.sub(r"""^'(?=\s)""", r"""‘""", str) # Special case for decade abbreviations (the '80s): str = re.sub(r"""\b'(?=\d{2}s)""", r"""’""", str) From 05beaaf1f3ab42aeea2b5a0f3c975cf1e8fcb537 Mon Sep 17 00:00:00 2001 From: Lee Date: Wed, 23 May 2012 02:42:05 +0800 Subject: [PATCH 2/3] commented the deleted lines out --- 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 c29b258722..7667c763c7 100644 --- a/src/calibre/utils/smartypants.py +++ b/src/calibre/utils/smartypants.py @@ -601,6 +601,10 @@ def educateQuotes(str): # Special case for Quotes at end of line with a preceeding space (may change just to end of line) str = re.sub(r"""(?<=\s)"$""", r"""”""", str) str = re.sub(r"""(?<=\s)'$""", r"""’""", str) + + # Special case for Quotes at beginning of line with a space - multiparagraph quoted text: + #str = re.sub(r"""^"(?=\s)""", r"""“""", str) + #str = re.sub(r"""^'(?=\s)""", r"""‘""", str) # Special case for decade abbreviations (the '80s): str = re.sub(r"""\b'(?=\d{2}s)""", r"""’""", str) From 364c5cf49296af54a9adfc554b0af060d227fc25 Mon Sep 17 00:00:00 2001 From: Lee Date: Wed, 23 May 2012 02:45:17 +0800 Subject: [PATCH 3/3] added comments --- src/calibre/utils/smartypants.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/utils/smartypants.py b/src/calibre/utils/smartypants.py index 7667c763c7..161d812df8 100644 --- a/src/calibre/utils/smartypants.py +++ b/src/calibre/utils/smartypants.py @@ -603,6 +603,9 @@ def educateQuotes(str): str = re.sub(r"""(?<=\s)'$""", r"""’""", str) # Special case for Quotes at beginning of line with a space - multiparagraph quoted text: + # This case commented out as it works under the assumption that the regex pattern will always + # evaluate a complete sentence - the tokenize function called earlier in smarty will break up + # the text based on tags, so sentence fragments can be passed to the patterns as well. #str = re.sub(r"""^"(?=\s)""", r"""“""", str) #str = re.sub(r"""^'(?=\s)""", r"""‘""", str)