Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 09-22-2011, 11:55 PM   #1
lindsayw
Author from pBook days
lindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watch
 
lindsayw's Avatar
 
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 >&quot; – replace these left double-quotes with >&ldquo;
2. Search-&-replace for (space)&quot; – replace these left double-quotes with (space)&ldquo;
3. Search-&-replace for &quot;(space) – replace these right double-quotes with &rdquo;(space)
4. Search-&-replace for &quot;< – replace these right double-quotes with &rdquo;<
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 &quot;& (where a &nbsp; or similar immediately follows the quote) – replace with &rdquo:&
6. Search-&-replace for ALL Apostrophe characters and replace them with &rsquo; ...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)&rsquo; – replace these with (space)&lsquo;

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.
lindsayw is offline   Reply With Quote
Old 09-23-2011, 04:04 AM   #2
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,097
Karma: 4571547
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by lindsayw View Post
Left double-quotes can occur only at the start of a line or after a space.
Or after a dash, or after an opening parenthesis

Quote:
Right double-quotes can occur only before a space or at the end of a line.
Or before a punctuation, can't you imagine a sentence ending "thus"?

Quote:
In html, the start or end of a line can be determined by > or < characters.
But those characters appear also elsewhere, like the start and end of italics.

Quote:
Citations, the only occurrence of left single-quotes, can start only after a space.
Or after a dash or parenthesis too. There can also be apostrophes after a space, 'tis possible to find 'em.

Quote:
1. Search-&-replace for >&quot; – replace these left double-quotes with >&ldquo;
Not all " are &quot;, actually, I never find &quot; in my files, and there are many " that must not be replaced.

Note also that "things like <em>this</em>" are possible

Quote:
4. Search-&-replace for &quot;< – replace these right double-quotes with &rdquo;<
And—"<em>this</em> is possible" too.

Quote:
7. Now you need to find and replace the left-sloping ones. Search-&-replace for (space)&rsquo; – replace these with (space)&lsquo;
Replace 'em all...

Last edited by Jellby; 09-24-2011 at 03:01 AM.
Jellby is online now   Reply With Quote
Old 09-23-2011, 02:00 PM   #3
lindsayw
Author from pBook days
lindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watch
 
lindsayw's Avatar
 
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.
lindsayw is offline   Reply With Quote
Old 09-23-2011, 03:32 PM   #4
lindsayw
Author from pBook days
lindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watchlindsayw is clearly one to watch
 
lindsayw's Avatar
 
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...
lindsayw is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 04:06 AM.


MobileRead.com is a privately owned, operated and funded community.