Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Parsedown wrapper to act as a drop-in replacement for PHP Markdown
<?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