Tag Archives: smart quotes

Smartquotes, Apostrophes, and which way to turn

So, I’m working on polishing up a manuscript, and guess what? My apostrophes were pointing the wrong way for certain kinds of contractions: Shoot ’em, ‘nother one for the road, ‘fraidy pants.

Think of apostrophes as the number 9

Think of a left single quote as a letter 6

So, words that start with an apostrophe should start with the letter 9.

Leave a comment

Filed under Grammar/Punctuation

Find unbalanced smart quotes in HTML using Perl

So I’m brushing up an HTML document so I can publish it on the Kindle and I’ve discovered lots of unbalanced smart quotes. Smart quotes are double quotes that face to the right or the left, rather than just straight up and down. In HTML, they are rendered as “ldquo” and “rdquo” with an ampersand in front of each and a trailing semi-colon. I wrote a little script to make sure that for every left side I had a right side, and print out the lines in which they do not match.

Here you go:

#!/usr/bin/perl

open(FILE,"./file.html") or die "Can't open file.html: $!\n";

while(<FILE>) {
   chomp();
   $line = "$_";

   $l = "ldquo";
   $r = "rdquo";   
   $lc = 0;
   $rc = 0;   

   $lc = () = $line =~ /$l/g;
   $rc = () = $line =~ /$r/g;

   print "Lc = $lc  Rc = $rc\n";
   if ($lc != $rc) {
      print "\n$line\n";
   }
}
close(FILE);

3 Comments

Filed under Grammar/Punctuation, Tools for Writers