Revision [8863]
This is an old revision of SmartyPants made by DarTar on 2005-06-06 11:59:20.
Smarty Pants: Smart typographic punctuations
This page gives instructions on how to install a 3rd party formatting engine for smart typographic punctuations in WikkaWiki
PHP SmartyPants is a port to PHP of the original SmartyPants written in Perl by John Gruber. SmartyPants is a free web publishing tool that translates plain ASCII punctuation characters into "smart" typographic punctuation HTML entities. SmartyPants can perform the following transformations:
- Straight quotes ( " and ' ) and backticks-style quotes (`` '') into curly quote HTML entities: “doublequotes” and ‘singlequotes’ ;
- Dashes (-- and ---) into en- and em-dash entities: – and — ;
- Three consecutive dots (...) into an ellipsis entity (…).
Installing SmartyPants in Wikka is straightforward and requires no specific modification to the original code.
The steps
1. Get the code
Download the latest version of http://www.michelf.com/projects/php-smartypants/2. Copy it in the wikka directory
Move the SmartyPants folder into /3rdparty/plugins3. Update the ConfigurationOptions Wikka configuration file
Add the following lines to wikka.config.php: "typography" => "1",
"smartypants_path" => "3rdparty/plugins/smartypants",
"smartypants_path" => "3rdparty/plugins/smartypants",
Make sure the smartypants path matches the name of the folder in which you have saved the code.
4. Create a Typography() method
Add the following function in wikka.php, for example right after the GeSHi_Highlight() function:
function Typography($text){
if (($this->GetConfigValue('typography') == 1) && file_exists($this->GetConfigValue('smartypants_path').'/smartypants.php')){
include_once($this->GetConfigValue('smartypants_path').'/smartypants.php');
$text = SmartyPants($text);
}
return $text;
}
if (($this->GetConfigValue('typography') == 1) && file_exists($this->GetConfigValue('smartypants_path').'/smartypants.php')){
include_once($this->GetConfigValue('smartypants_path').'/smartypants.php');
$text = SmartyPants($text);
}
return $text;
}
5. Modify the formatter
Open ./formatter/wakka.php, scroll to the end of the file and add the following line, immediately before echo $text;
$text = $this->Typography($text);
That's all folks...
CategoryDevelopment3rdParty CategoryDevelopmentFormatters