Skip to content

PHP Markdown for CI 1.5.x

Derek Jones edited this page · 7 revisions
Clone this wiki locally

Correction: Ignore the below unless you really need Markdown to be a library for some reason. Much easier to make it a helper - just put the original markdown.php, with no changes, into your system/helpers or application/helpers directory as markdown_helper.php. Then $this->load->helper('markdown'); and $text = markdown($text);

I added just a few lines of code to PHP Markdown to integrate it as a CI library. This is a much less extensive hacking of the PHP Markdown source than the other CI integration (labeled for CI 1.4.x) already in the files area.

I can't see where to upload a file to this wiki, but just download PHP Markdown 1.0.1f, place it in your libraries/ folder as mkdn.php, and add these lines:


### CodeIgniter Library Interface ###

# rename this file to mkdn.php and place in libraries dir
# Usage:
# $this->load->library('mkdn');
# $this->mkdn->translate($text);
if(defined('BASEPATH')) {
    class Mkdn {
        function translate($text) {
            return Markdown($text);
        }
    }
} 
Something went wrong with that request. Please try again.