diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index d9a7b76..4d0251d 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -426,23 +426,17 @@ return this } - , parseContent: function() { - var content, - callbackContent = this.$options.onPreview(this) // Try to get the content from callback - - if (typeof callbackContent == 'string') { - // Set the content based by callback content - content = callbackContent + , parseContent: function(val) { + var content + + // parse with supported markdown parser + var val = val || this.$textarea.val(); + if(typeof markdown == 'object') { + content = markdown.toHTML(val); + }else if(typeof marked == 'function') { + content = marked(val); } else { - // Set the content - var val = this.$textarea.val(); - if(typeof markdown == 'object') { - content = markdown.toHTML(val); - }else if(typeof marked == 'function') { - content = marked(val); - } else { - content = val; - } + content = val; } return content; @@ -453,14 +447,17 @@ container = this.$textarea, afterContainer = container.next(), replacementContainer = $('
',{'class':'md-preview','data-provider':'markdown-preview'}), - content + content, + callbackContent // Give flag that tell the editor enter preview mode this.$isPreview = true // Disable all buttons this.disableButtons('all').enableButtons('cmdPreview') - content = this.parseContent() + callbackContent = options.onPreview(this) // Try to get the content from callback + // Set the content based from the callback content if string otherwise parse value from textarea + content = typeof callbackContent == 'string' ? callbackContent : this.parseContent(); // Build preview element replacementContainer.html(content)