CurlyQuotes-Talk
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', "/---([^-])/", '—$1' );
# n-dash (beware [-- and --])
Markup( "ndash", 'inline', "/[^\\[]--([^-\\]])/", '–$1' );
# ellipsis
Markup( "...", 'inline', "/\.\.\./", '…' );
}
Tony Colley July 18, 2006, at 01:03 PM
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', "/\"-/", '“' ); Markup( "rdquo", 'inline', "/-\"/", '”' );
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 (.*?):\\]/',
"“$1”" );
# [:sq text:] wraps text in curly single quotes
Markup( 'squo', 'directives', '/\\[:sq (.*?):\\]/',
"‘$1’" );
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’$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',"/\"(.*?)\"/",'“$1”');
Markup(chr(147),'_end',"/".chr(147)."/",'“');
Markup(chr(148),'_end',"/".chr(148)."/",'”');
# make m-dash
Markup("---",'_end',"/---([^-])/",'—$1');
Markup(chr(151),'_end',"/".chr(151)."/",'—');
# make n-dash
Markup("--",'_end',"/--([^-])/",'–$1');
Markup(chr(150),'_end',"/".chr(150)."/",'–$1');
# curly single quote in contraction
Markup("a'a",'_end',"/([A-Za-z])'([A-Za-z][A-Za-z]?[^A-Za-z])/",'$1’$2');
Markup(chr(146),'_end',"/".chr(146)."/",'’');
}
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',"/\"(.*?)\"/",'“$1”');
Talk page for the CurlyQuotes recipe (users).