CurlyQuotes-Talk

Summary: Talk page for CurlyQuotes.
Maintainer:
Users: (View? / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Comments

For me, the m-dash rule above didn't work because PmWiki tried to do the n-dash rule first (so I got -– instead of — for ---). I also didn't see the need to put all the markup at the "_end" (though it is necessary for the curly quotes, else things like alt text for images don't work). Here's my solution (with an additional markup for ellipsis to turn ... into … — this isn't needed if you use MarkupExtensions):

if ($action != 'edit') {
# curly double quotes
  Markup( "dquo", '_end', "/\"(.*?)\"/", '“$1”' );
# curly single quote in contraction 
  Markup( "squo", '_end', "/([A-Za-z])'([A-Za-z][A-Za-z]?[^A-Za-z])/", '$1’$2');
# m-dash 
  Markup( "mdash", '<ndash', "/---([^-])/", '&mdash;$1' );
# n-dash (beware [-- and --])
  Markup( "ndash", 'inline', "/[^\\[]--([^-\\]])/", '&ndash;$1' );
# ellipsis
  Markup( "...", 'inline', "/\.\.\./", '&hellip;' );
}

Tony Colley July 18, 2006, at 01:03 PM


Note: if you use the "ndash" markup, beware that this will mess with any links you have with "--" in them (for example, Yahoo! 360 blog entry permalinks often have two dashes together). So, you must change "--" to "%2D%2D" (the corresponding URL encoding).

TonyColley July 23, 2006, at 11:09 AM


Actually, this still didn't quite work because using " as a symbol for seconds or inches caused problems. Also, if you do a multiparagraph quote, it didn't handle the opening quote at the beginning of any but the last paragraph.

So, I gave up on automatically determining where curly double quotes were appropriate and created a shorthand for entering left and right curly double quotes:

# curly double quotes
Markup( "ldquo", 'inline', "/\"-/", '&ldquo;' );
Markup( "rdquo", 'inline', "/-\"/", '&rdquo;' );

And I created a couple of directives to wrap text in curly quotes:

# [:dq text:] wraps text in curly double quotes
Markup( 'dquo', 'directives', '/\\[:dq (.*?):\\]/',
        "&ldquo;$1&rdquo;" );
# [:sq text:] wraps text in curly single quotes
Markup( 'squo', 'directives', '/\\[:sq (.*?):\\]/',
        "&lsquo;$1&rsquo;" );

Finally, I did keep the markup for automatically converting ' to ’ in contractions and possessives (except possessives of words ending in "s", e.g. "James' dog"):

# curly single quote in contraction 
Markup( "apostrophe", '_end', "/([A-Za-z])'([A-Za-z][A-Za-z]?[^A-Za-z])/",
        '$1&rsquo;$2');

TonyColley July 19, 2006, at 02:04 PM


If you're pasting text into the wiki from another program, including html2wiki, you may find that perfectly valid curly quotes get turned into high-ASCII characters by your operating system. I guess the ideal way to handle this would be to intercept them when the form is submitted and save them as standard straight quotes, but as a stopgap I've extended this curly-quote recipe to turn the Windows high-ASCII characters into valid curly quotes when the page is rendered:

if ($action != 'edit') {
 # make curly quotes 
 Markup("\"",'_end',"/\"(.*?)\"/",'&#8220;$1&#8221;');
 Markup(chr(147),'_end',"/".chr(147)."/",'&#8220;');
 Markup(chr(148),'_end',"/".chr(148)."/",'&#8221;'); 
 # make m-dash 
 Markup("---",'_end',"/---([^-])/",'&#8212;$1');
 Markup(chr(151),'_end',"/".chr(151)."/",'&#8212;'); 
 # make n-dash 
 Markup("--",'_end',"/--([^-])/",'&#8211;$1'); 
 Markup(chr(150),'_end',"/".chr(150)."/",'&#8211;$1');
 # curly single quote in contraction
 Markup("a'a",'_end',"/([A-Za-z])'([A-Za-z][A-Za-z]?[^A-Za-z])/",'$1&rsquo;$2');
 Markup(chr(146),'_end',"/".chr(146)."/",'&rsquo;');
}

If you're using an OS other than Windows to do your editing, you may need to change the chr() numbers to match the characters your OS is serving up. I got these character numbers from the HTML Validator when I tried to validate my wiki pages!

Ben Stallings July 18, 2006, at 11:17 AM


This markup is not good with pmwikidraw!! The links/URLs are destroyed!!!
Markup("\"",'_end',"/\"(.*?)\"/",'&#8220;$1&#8221;');


Talk page for the CurlyQuotes recipe (users?).