ruby-on-railssyntax-highlightingblogs

Any gem for designing a blog post in Rails with syntax highlighting and inline image attachment?


I am trying to make a personal blog in Ruby on Rails. I want to design individual post with syntax highlighting as well as inline multiple image attachment. I have tried ckeditor gem with paperclip but the syntax highlighting doesn't work with redcarpet and pygments.rb.

I am looking to create the blog post something similar to this.Please help !!


Solution

  • Obtvse, an open source blog engine inspired by Svbtle does pretty much exactly what you are looking for.

    It uses Coderay for syntax highlighting which is a pure ruby library and does not depend on javascript, and Markdown (through Kramdown) for editing posts rather than a WYSIWYG solution like CKEDITOR which IMHO is a more sane choice - especially for technically inclined.

    Backend based syntax highlighting plays well with RSS readers as opposed to javascript based solutions.

    You can either use the application and customize as per your requirements, or take a look at the implementation and use that to build your own solution.

    Alternatively if you are specifically inclined towards using CKEditor you might want to take a look at this plugin which integrates CKEditor with CodeMirror, which is among the most popular solutions for code editing and highlighting in javascript. For displaying the snippets you can also use CodeMirror in a readonly mode as described in this manual. This will ensure that you get the exact same syntax highlighting while editing as well in post view page.