Closed ryanburnette closed 10 years ago
Hi Ryan,
Not at all :).
The plug-in exposes two functions (see https://github.com/stephenharris/WP-MarkDown/blob/1.4/wp-markdown.php#L519). One for converting Markdown to HTML and the other doing the opposite. You can use those functions in any other plug-in.
As for filters when Markdown is run - there isn't, the plug-in uses WordPress' filters, so you can just use the same hooks (before/after wp-markdown's callback depending on whether you want the content in HTML or markdown when you perform your routine). I may add two filters in the above mentioned functions.
Thanks for getting back to me!
I'll definitely make use of this. It would be very WordPressy if these functions were WordPress filters, too.
I still think this would be a good addition to the plugin. If you want I can do a pull request. It's as easy as this.
function markdown_func($content) {
if ( function_exists('wpmarkdown_markdown_to_html') ) {
return wpmarkdown_markdown_to_html($content);
}
return $content;
}
add_filter('markdown','st_markdown_func');
Hi Ryan,
The above uses the filter markdown
- this isn't a filter used by the plug-in or WordPress, so it's not clear to me what its filtering, or when its filtering it...
Or is it a case of:
$markdown = '...some text in markdown...';
$html = apply_filters( 'markdown', $markdown )
If so, I don't think a filter here is necessary, just call:
$html = markdown_func( $markdown );
It's a WordPress plugin so my opinion is that offering a filter is cleaner. Same diff in the end. Closing.
But just in case anyone is like me and wants to utilize this functionality using filters, here's the code.
@stephenharris I hope creating an issue on your Github repo isn't too invasive, but I'm curious about a couple things and I haven't found an answer in your documentation. There are a couple things I'd like to do with Filters and WP-Markdown.
One is that I'd like to use the Markdown filter for text I store in custom fields. Is there a way to use
apply_filters
to process Markdown that I've stored on my own?Also, I'd like to add processing to the filter which processes the Markdown. This is less important as I can filter using the
the_content
filter tag, but it might be cool to add additional processing using PHP that I keep in a separate plugin on certain projects.Thanks in advance!
Ryan