SmartQuotes

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Problem

Curly quotes look better than straight quotes and make pages more readable.

Solution

This script automatically turns straight quotes into curly quotes, -- into em dashes, ... into ellipses, and << ... >> or < ... > into angle quotes.

It also checks numbers: digit-digit becomes digit en dash digit and digit quote becomes digit prime (′ or ″). You can prevent a prime with a backtick quote, which comes out as a right quote mark.

Attach:smartquotes.php - source code (works with PmWiki 1.0 and above; it should work fine with earlier versions)

Discussion

Put smartquotes.php in your local directory and add the line include_once("local/smartquotes.php") to local.php.

Mostly, it just works. But…

Word processors have to be fooled to put a right quote at the start of a word (such as '90s) and SmartQuotes is no different. If you write `'90s (backtick-quote), it gets rendered as ’90s.

You can also force an en dash (such as the Wellington–Picton ferry) with `- (backtick hyphen).

The script affects page displays only; your page source is unchanged.

If you have installed PageTableOfContents, you already have smart quotes.

There was a flaw in an earlier version: it made the opening quote inside markup such as @@"some text"@@ come out as a right quote. This is now (27 June 2003) fixed. JR

Contributors

pmwiki-2.2.115 -- Last modified by {{jr}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons