09-22-2011, 11:55 PM | #1 |
Author from pBook days
Posts: 49
Karma: 10782
Join Date: Mar 2011
Location: Australia
Device: Kindle-3-Keyboard; 8" Android Tablet
|
Making 'Smart Quotes' in (x)html
Removing (x)html vertical single- and double-quotes, replacing them with sloping single- and double-quotes, similar to the ‘smart quotes’ used by Word Processors.
Consider the short extract: “Hello” he said, “How’s your ‘phantom’ illness?” – this includes left and right double-quotes; left and right single-quotes (citation) and a plain apostrophe. In html, these all render in vertical quotes unless they are specifically coded otherwise. Left double-quotes can occur only at the start of a line or after a space. Right double-quotes can occur only before a space or at the end of a line. In html, the start or end of a line can be determined by > or < characters. Citations, the only occurrence of left single-quotes, can start only after a space. Use “global” Search-&-replace to modify all html files in a given folder. 1. Search-&-replace for >" – replace these left double-quotes with >“ 2. Search-&-replace for (space)" – replace these left double-quotes with (space)“ 3. Search-&-replace for "(space) – replace these right double-quotes with ”(space) 4. Search-&-replace for "< – replace these right double-quotes with ”< 5. Some right-quotes will have been missed, when an actual space does not immediately follow it in the html code, so Search-&-replace for "& (where a or similar immediately follows the quote) – replace with &rdquo:& 6. Search-&-replace for ALL Apostrophe characters and replace them with ’ ...this replaces ALL single-quotes with right-sloping characters. 7. Now you need to find and replace the left-sloping ones. Search-&-replace for (space)’ – replace these with (space)‘ This does rely on your html code being “tight” and predictable, with no variances. You can’t have, for instance: ....end of sentence.</div> on one line but: ...end of sentence. (line break or space) </div> on another. There are also occasional instances of periods outside a quote rather than inside, so an extra check would be required to catch them, but I didn’t bother because I knew the content well enough to know that they didn’t occur. I modified a 40-document book, 150k words, in ten minutes! Whoopee! I am still proof-reading, of course, to be sure that all instances were changed, but the worst that could happen is that one or two single- or double-quotes would remain as plain vertical ones. And the sloping quotes provide a much better reading experience. Last edited by lindsayw; 09-22-2011 at 11:58 PM. |
09-23-2011, 04:04 AM | #2 | |||||||
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
Quote:
Quote:
Quote:
Note also that "things like <em>this</em>" are possible Quote:
Quote:
Last edited by Jellby; 09-24-2011 at 03:01 AM. |
|||||||
Advert | |
|
09-23-2011, 02:00 PM | #3 |
Author from pBook days
Posts: 49
Karma: 10782
Join Date: Mar 2011
Location: Australia
Device: Kindle-3-Keyboard; 8" Android Tablet
|
All of these instances are correct (especially the 'tis right apostophe after a space, which would be incorrectly converted to a left-sloping single-quote by my simple method) but rare. I am quite happy to identify those few instances by proof-reading. I also have the advantage of knowing exactly what's in my own stuff! Most of them simply never occur.
But useful, useful. |
09-23-2011, 03:32 PM | #4 |
Author from pBook days
Posts: 49
Karma: 10782
Join Date: Mar 2011
Location: Australia
Device: Kindle-3-Keyboard; 8" Android Tablet
|
I suppose that I really should explain 2 things:
1. I started writing about 30 years ago, so I have lots of books converted to html more than a decade ago, when plain vertical quotes were the only option available – sloping quotes just did not render properly on most displays. So this simple method applies to html files with old-fashioned code that specifically avoided sloping quotes. 2. Every writer finds a "voice", which is just a preferred method of handling grammatical rules. I personally never use em-dashes abutting words—I find it ugly. I use lots of en-dashes – like this – but always separated by spaces. So my method avoids seeking out occurrences that I know will never happen. So it works FOR ME because I know what my files contain. ...but it may help other old farts... |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre and Smart Quotes | salasnet | Calibre | 9 | 09-27-2010 04:32 AM |
Smart Quotes | Toxaris | ePub | 2 | 05-31-2010 10:32 AM |
Smart quotes in XHTML? | MaggieScratch | ePub | 12 | 03-28-2009 05:53 PM |
Removing smart quotes | horseyride | Workshop | 8 | 03-06-2008 12:08 PM |
Smart quotes in RTF? | ogghead | Sony Reader | 8 | 01-23-2007 06:38 PM |