SmartQuotes

Summary: Turns straight quotes into smart quotes
Version: 2017-12-30
Prerequisites: Recent version of PmWiki (tested on 2.2.106)
Status: Maintained
Maintainer: Said Achmiz
License: GPL
Categories: Markup
Users: (view? / edit)
Discussion: SmartQuotes-Talk

Questions answered by this recipe

How do I automatically turn straight quotes (' ' " ") into smart quotes (‘ ’ “ ”, or as appropriate for my language)?

Description

Turns straight quotes into smart quotes when displaying a page. (You can adjust the style of smart quotes as appropriate for your language.)

Installation

Download smartquotes.phpΔ and place it in your cookbook directory. Then add such a line to config.php:

 include_once("$FarmD/cookbook/smartquotes.php");

Configuration

Prior to including smartquotes.php, set $SmartQuoteStyle as appropriate to your language, e.g.

 $SmartQuoteStyle = 'GB';

Options include: 'CH', 'DE', 'DK', 'ES', 'FI', 'FR', 'GB', 'NL', 'PL', 'SE'. (Default is 'GB'.)

Notes

The code for this recipe was extracted from MarkupExtensions. All credit goes to that recipe’s author/contributors; I just packaged it as a standalone recipe.

Alternative method

You can also use a Javascript-based solution:

  1. Download smartquotes.js and place it in your pub/ directory.
  2. Add the following to your config.php:
## Smartquotes.js
if ($action == 'browse') {
	$HTMLFooterFmt['smartquotes-js'] = "
<script src='$FarmPubDirUrl/smartquotes.js'></script>
<script>smartquotes().listen();</script>
";
}

Change log / Release notes

  • 2018-01-08: Added JS-based method.
  • 2017-12-30: Initial release.

Contributors

Comments

See discussion at SmartQuotes-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.