Created
March 30, 2014 15:29
-
-
Save oelna/9874443 to your computer and use it in GitHub Desktop.
A Parsedown wrapper to act as a drop-in replacement for PHP Markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* makes the 'Markdown" function and the 'Markdown_Parser' class available to your scripts */ | |
require( 'parsedown.php' ); | |
@define( 'MARKDOWN_PARSER_CLASS', 'Markdown_Parser' ); | |
@define( 'NEWLINE_TO_BREAK', true ); | |
function Markdown($text) { | |
static $parser; | |
if (!isset($parser)) { | |
$parser_class = MARKDOWN_PARSER_CLASS; | |
$parser = new $parser_class; | |
} | |
return $parser->transform($text); | |
} | |
class Markdown_Parser extends Parsedown { | |
function transform($text) { | |
if(NEWLINE_TO_BREAK) self::set_breaks_enabled(true); | |
return self::parse($text); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment