Hello everybody! At the moment I am building my new Website. On my Website, users are allowed to post some code (Java, Rails, Ruby, HTML, CSS,...). Now I want to format that code in frontend like on Stackoverflow. Is there a plugin I can use in Rails? I had a look on some rich text editors, but most of them did not do what I wanted them to do. I really like the Code highlighting on Stackoverflow. Any ideas how to do this?
Code formatting on SO is done using the Markdown syntax ( also see Jeff's blog post). The actual editor itself seems to be a customised version of the WMD editor, which features a JavaScript implementation of Markdown.
It's been a while since I did any Ruby on Rails, but the last time I did you could add Markdown support to your project by installing the BlueCloth gem. It would be up to you if you also want to include WMD on the front-end. I used WMD on an ASP.NET MVC project, and it worked well... apart from the users didn't like it, so I ended up removing it!
37Signals editor has now been released. It is worth a look and designed to allow you to extend it.
I have used WMD Editor and the BlueCloth gem on a project and it is working well. You don't need a plugin to implement the Stack Overflow style. Just require the Bluecloth gem to render the Markdown that is submitted by the WMD Editor. WMD Editor provides the live preview that you see on stack overflows pages and is just a javascript library that needs to be included.