Skip to content

Instantly share code, notes, and snippets.

@christopherscott
Created June 21, 2012 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherscott/2966415 to your computer and use it in GitHub Desktop.
Save christopherscott/2966415 to your computer and use it in GitHub Desktop.
setting up wysiwym jquery plugin
// setup wysiwym
$(function() {
$("#post-body textarea").wysiwym(Wysiwym.Markdown, {});
// setup live preview
var showdown = new Showdown.converter();
var prev_text = "";
var update_live_preview = function() {
var input_text = $("#post-body textarea").val();
if (input_text != prev_text) {
var text = $("<div>"+ showdown.makeHtml(input_text) + "</div>");
text.find("pre").addClass("prettyprint");
text.find("p code").addClass("prettyprint");
text.find("code").each(function(){
$(this).html(prettyPrintOne($(this).html()));
});
$("#post-preview").html(text);
prev_text = input_text;
}
};
setInterval(update_live_preview, 200);
});
@christopherscott
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment