![]() |
#1 |
Perfectionist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
|
Find straight quotes in the text
I'm editing an OCRd book with mixed straight and curly double quotes. Is there a way to find the straight ones in the text, outside the HTML tags, and replace them with the curly ones? A regular expression maybe?
|
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,003
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Smarten Punctuation is a built in tool |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Perfectionist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
|
|
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,301
Karma: 27111240
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, there isn't. In general the problem of converting straight quotes to curly quotes cannot be solved robustly without understanding the actual text.
|
![]() |
![]() |
![]() |
#5 | |
Perfectionist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
|
Quote:
How does Smarten Punctuation convert them? Is there something from the SP routine one could use in Search and Replace to deal with straight quotes manually? |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,301
Karma: 27111240
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It uses an algorithm and that algorithm is not foolproof.
|
![]() |
![]() |
![]() |
#7 |
Perfectionist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
|
OK, nailed the find part
![]() To find single straight quotes outside HTML tags, search for '(?!([^<]+)?>) To find double straight quotes outside HTML tags, search for "(?!([^<]+)?>) The replace part is tricky, but that can be done manually, at least in my case, with relatively few instances of straight quotes. |
![]() |
![]() |
![]() |
#8 | |
New old guy
![]() Posts: 69
Karma: 10
Join Date: Feb 2012
Device: kindle fire
|
Quote:
|
|
![]() |
![]() |
![]() |
#9 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,621
Karma: 145864263
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Is there any easy way to find single quotes (not straight) that are not part of a contraction in order to convert them to double quotes? I find it odd reading a UK style eBook that has single quotes where I normally expect double quotes.
|
![]() |
![]() |
![]() |
#10 | |
Perfectionist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
|
Quote:
Nothing specific, but a lot of info is available here: http://www.regular-expressions.info/ |
|
![]() |
![]() |
![]() |
#11 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,696
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Left single quote - in Insert Character (ctrl/alt/i) favourites (factory)
For dialogue will normally be preceded by space or a marker of some sort. But dialogue is not the only place they're used, I like to leave them single for things like... he played Billy Holiday’s ‘I Cover the Waterfront’ all night.... BR Last edited by BetterRed; 07-12-2014 at 09:42 PM. |
![]() |
![]() |
![]() |
#12 | |
Perfectionist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 72
Karma: 12802
Join Date: Apr 2014
Device: none
|
Quote:
I believe this should cover it, but it will replace all the quotes, both in dialogues and outside them, except those that are part of a contraction. Of course, the book must have proper punctuation to begin with. 1) Replace opening single curly quotes with opening double curly quotes Search: ‘ Replace: “ 2) Replace closing single curly quotes with closing double curly quotes (two passes) Search: ([.|…|,|:|;|?|!|\-|–|—])’ Replace: \1” Search: ’([ |.|…|,|:|;|?|!|\-|–|—]) Replace: ”\1 Some of the combinations are unlikely to be found, but I guess better an overkill than missed instances ![]() |
|
![]() |
![]() |
![]() |
#13 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,696
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
When converting single to double or visa versa one needs to be careful not to 'spoil' 6' 3" (Imperial length) 20' 15" (Time) and 33° 52' 34" S, 151° 13' 24" E (Geolocation). And I've never seen an automated straight to curly that preserves the straight quotes on measurements. Shouldn't be too hard, if preceded by a digit leave it alone. Depends on the font, but to my eyes line B looks wrong. A - 6' 3" (Imperial length) 20' 15" (Time) and 33° 52' 34" S, 151° 13' 24" E B - 6’ 3” (Imperial length) 20’ 15” (Time) and 33° 52’ 34” S, 151° 13’ 24” E I might start using « » on dialogue instead of “ ” ![]() BR Last edited by BetterRed; 07-13-2014 at 01:11 AM. |
|
![]() |
![]() |
![]() |
#14 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,301
Karma: 27111240
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Smarten punctuation does preserve straight quotes on measurements. https://bugs.launchpad.net/calibre/+bug/1285351
To be precise it replaces them with the correct typographic prime |
![]() |
![]() |
![]() |
#15 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,696
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
Added - and C looks even better (best) ![]() C - 6′ 3″ (Imperial length) 20′ 15″ (Time) and 33° 52′ 34″ S, 151° 13′ 24″ E BR Last edited by BetterRed; 07-13-2014 at 02:36 AM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Reducing file size for straight-text epub? | Christi H | ePub | 5 | 01-10-2013 10:09 PM |
Looking for a tool to find/fix mis-matched quotes... | therealjoeblow | Calibre | 4 | 09-04-2011 01:25 AM |
convert straight quotes to curly quotes | alansplace | Calibre | 3 | 09-25-2010 03:51 PM |
What's with all the straight quotes (inch marks)? | DGReader | ePub | 35 | 03-03-2010 02:48 PM |
Pielrf - Text to LRF with Easy TOC, Headers, Curly-Quotes, etc. (Mac!) | EatingPie | LRF | 104 | 01-12-2009 12:35 PM |