Revision [8870]

This is an old revision of SmartyPants made by DarTar on 2005-06-06 12:11:20.

 

Smarty Pants: Smart typographic punctuations


This page provides instructions on how to install a 3rd party formatting engine for smart typographic punctuations in WikkaWiki


 


The functionality

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:

SmartyPants does not modify characters within <pre>, <code>, <kbd>, or <script> tag blocks. Typically, these tags are used to display text where smart quotes and other "smart punctuation" would not be appropriate, such as source code or example markup.

Known issues
(from: http://daringfireball.net/projects/smartypants/)
One situation in which quotes will get curled the wrong way is when apostrophes are used at the start of leading contractions. For example:
’Twas the night before Christmas.
In the case above, SmartyPants will turn the apostrophe into an opening single-quote, when in fact it should be a closing one. I don't think this problem can be solved in the general case - every word processor I've tried gets this wrong as well. In such cases, it's best to use the proper HTML entity for closing single-quotes by hand.

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
Unzip the SmartyPants folder and move into /3rdparty/plugins

3. Update the ConfigurationOptions Wikka configuration file
Add the following lines to wikka.config.php:

    "typography" => "1",
    "smartypants_path" => "3rdparty/plugins/smartypants",


Make sure the smartypants path matches the name of the folder in which the code is contained.

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;
    }


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
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki