Markdown experiment

in Userscripts.org discussion
Subscribe to Markdown experiment 8 posts, 6 voices



Jesse Andrews Admin
ChromeMacintosh

I've been exploring how to improve the markup situation of the site. I kinda like StackOverflow's editor - with inline previewing. They previously reverse engineered the JavaScript markdown editor for which they only had obfuscated code. They have a C# implementation for the server side they just open source called MarkdownSharp. In the comments someone asked:
Why not just have 1 JS version and call into it from C#?
Which made me realize I should be doing that for userscripts.org. So I created a simple node.js server to prototype running showdown on the server side. The code is very simplistic right now, but you can test it at http://userscripts.org:8000/ The code I'm using right now is from tstone's jquery-markedit repo.
var sys = require('sys'), 
    parser = require('./querystring-parse'),
    sh = require('./showdown'),
    http = require('http');

var MarkEditShowDown = sh.converter;

http.createServer(function (req, res) {
  if (req.method == 'GET') {
    res.sendHeader(200, {'Content-Type': 'text/html'});
    res.sendBody("<form><textarea></textarea>
<input /></form>"); res.finish(); } else { var body = ""; req.addListener("body", function(chunk) { body += chunk; }); req.addListener("complete", function() { res.sendHeader(200, {'Content-Type': 'text/html'}); res.sendBody(MarkEditShowDown.makeHtml(parser.parse(body)['text'])); res.finish(); }); } }).listen(8000); sys.puts('Server running at http://127.0.0.1:8000/');
 
Marti Scriptwright
FirefoxX11

Looks interesting especially on the abstraction of links... although, in general, it's beginning to be a drain on mental resources that no standard besides HTML markup has been employed across the world wide web for formatting and linkage. (GitHub has one way which has changed over the last few months, Goo has another, etc...).

 
Jesse Andrews Admin
ChromeMacintosh

I'm going to use github's example result to make sure our markdown is the same as theirs (except the github specific stuff). It isn't yet - emails aren't linked and the first "rose are red violets are blue" doesn't render correctly.

 
Joshua McKenty Scriptwright
ChromeMacintosh

I think it's a great idea - but we won't really be able to tell until it works in these reply boxes, right?

 
Yansky Scriptwright
FirefoxWindows

Jesse, you might find these blog posts interesting:
http://whirlpool.net.au/blog/8
http://whirlpool.net.au/blog/9
http://whirlpool.net.au/blog/10

 
Tim Smart Scriptwright
FirefoxMacintosh

Markdown is awesome. For a concept run, try this: http://userscripts.org/scripts/show/70901

Also, nice to see the use of Node.js :D You might want to check out the latest API additions and changes though.

 
sizzlemctwizzle Scriptwright
SafariMacintosh

@Jesse
Do you think we can have markdown implemented in the forum anytime soon? I'd really be great.

 
Tim Smart Scriptwright
FirefoxX11

A quick update. I have implemented a DOM -> Markdown parser in ecmascript. You can take a look here http://userscripts.org/scripts/show/104570 (Example script that uses it USO, meet Markdown)

If you find a bug all my code is hosted at https://github.com/Tim-Smart/userscripts , where you can file an issue report or patch.