Support Markdown syntax in P2 posts and comments
<?php | |
// http://michelf.com/projects/php-markdown/extra/ | |
require_once( dirname(__FILE__) . '/markdown-extra/markdown-extra.php' ); | |
/** | |
* Format posts/comments with Markdown at display time. Only process | |
* blocks starting with \^md\s+. | |
**/ | |
function p2mis_comment_markdown( $text ) { | |
if( ! function_exists('Markdown') ) { | |
return $text; | |
} | |
if( preg_match( '/^\^md\s+/i', $text ) ) { | |
$text = preg_replace( '/^\^md\s+/i', '', $text ); | |
$text = Markdown($text); | |
} | |
return $text; | |
} | |
add_filter( 'comment_text', 'p2mis_comment_markdown', 1 ); | |
add_filter( 'the_content', 'p2mis_comment_markdown', 1 ); | |
// Remove the P2 list processing, which converts lists to HTML on save | |
add_filter( 'p2_add_component_post-list-creator', '__return_false' ); | |
add_filter( 'p2_add_component_comment-list-creator', '__return_false' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment