SmartQuotes
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:
- Download
smartquotes.js
and place it in yourpub/
directory. - 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
- jr (original MarkupExtensions recipe)
- Said Achmiz (extracted smart-quotes code from MarkupExtensions and packaged as a standalone recipe)
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.