How can I get Wordpress to save comments in markdown format? How can I get Wordpress to save comments in markdown format? wordpress wordpress

How can I get Wordpress to save comments in markdown format?


Nice question. As this feature is not available in the Wordpress plugin, you'll need to do some hackery at least to stop it from saving in HTML format, which you have done.

Now you need for when the comments are displayed to process that markdown into HTML. So let's use the comment_text hook:

<?php add_filter('comment_text', 'Markdown'); ?>

If you don't want your original code to feel like "hackery" -- turn it into a feature. Add a config option to the Markdown.php $save_format = 'html' or $save_format = 'markdown' then check if you want to execute the stripper function or not. In fact, you could be really smart and turn all of this into a function inside of Markdown.php (and remember to tell the author about your new feature, he might even update his original code ;)

function set_save_format($format) {  if ($format == 'markdown') {    // Ok we need to change the format of any comments output to html:    add_filter('comment_text', 'Markdown');  }}