Text to HTML string parsing a la Reddit Comments

Go To StackoverFlow.com

0

I've been poking through the source code for Reddit (https://github.com/reddit/reddit/wiki) for the past few hours and I can't find what I'm looking for: the function that does the flat text to HTML conversion for their comments.

If you're not familiar, on the site it has a table showing you how to format your comment and converts your plain text into html for links, bold, italic, etc.

Link: http://www.reddit.com/r/technology/comments/rupkj/5000_artists_line_up_for_a_pirate_bay_promotion/c48sy1v (Hit "reply" then "formatting help" to see the table of formatting options.)

Sample input:

This should be: **bold** and **I'm also bold**

This should be: *italic* and *I'm italic too*

This should be: ~~strikethrough text~~

This should be: [A Link To Google.com](http://www.google.com)

This should be A list:
*This is a list
*Of differnet
*Things that I like

Any idea how to accomplish this elegantly with regex?

2012-04-05 18:37
by NotJustClarkKent
Are you looking for a Markdown parser - Qtax 2012-04-05 18:38
I sure was!!!! That's exactly what I was looking for. Thanks Qtax - NotJustClarkKent 2012-04-05 18:52
Qtax, can you put that as an answer so I can give you Karma? : - NotJustClarkKent 2012-04-05 19:33
For those that happen upon this, I also found this blog post from Reddit about their comment system - NotJustClarkKent 2012-04-06 00:10


1

As said in the comments, you are probably looking for Markdown.

2012-04-05 21:38
by Qtax
Ads