Created
June 21, 2012 15:33
-
-
Save christopherscott/2966415 to your computer and use it in GitHub Desktop.
setting up wysiwym jquery plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from: http://pushingkarma.com/projects/jquery-wysiwym/