I’m working on a commenting system that uses Markdown and I want to have a live preview area where people can see what the final text will look like, like StackOverflow’s editor.
I’m currently using the following code to render the text inputted by the user:
$('#response_text').bind('blur keyup',function() {
$('.comment_preview').text($('#response_text').val());
$('.comment_preview').html($('.comment_preview').html().replace(/\n/g,'<br />').replace('* * *', '<hr />'));
});
And I don’t know how to replace stuff like **text** into <b>text</b>.
If you have any suggestions I would love to hear them.
Thanks!
I would also recommend using a plugin for this, but to answer your question: