Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery/JS Markdown plugin?

I'm writing a chat app, and I'd like to add some simple functionality where users use markup to affect text formatting, like bold or italics. I'm envisioning this would be like how it is done on Google Talk or StackOverflow. Does JQuery have any plugins to do this?

like image 852
Nick Heiner Avatar asked Apr 09 '10 01:04

Nick Heiner


2 Answers

stackoverflow is using WMD editor. You can use WMD editor code. It's written by javascript.

check

https://blog.stackoverflow.com/2009/01/wmd-editor-reverse-engineered/

For WMD to HTML , you can use ShowDown javascript.

Github source (include showdown.js)

http://github.com/derobins/wmd

Showdown usages

var text = "Markdown *rocks*.";
var converter = new Attacklab.showdown.converter();
var html = converter.makeHtml(text);
alert(html);
like image 75
saturngod Avatar answered Oct 10 '22 08:10

saturngod


It’s easy to use Showdown with or without jQuery. Here’s a jQuery example:

// See http://mathiasbynens.be/notes/showdown-javascript-jquery for a plain JavaScript version as well
$(function() {
 // When using more than one `textarea` on your page, change the following line to match the one you’re after
 var $textarea = $('textarea'),
     $preview = $('<div id="preview" />').insertAfter($textarea),
     converter = new Showdown.converter();
 $textarea.keyup(function() {
  $preview.html(converter.makeHtml($textarea.val()));
 }).trigger('keyup');
});
like image 37
Mathias Bynens Avatar answered Oct 10 '22 10:10

Mathias Bynens