在Rails中设计带有语法高亮和内嵌图像附件的博客文章有什么用吗? [英] Any gem for designing a blog post in Rails with syntax highlighting and inline image attachment?

查看:75
本文介绍了在Rails中设计带有语法高亮和内嵌图像附件的博客文章有什么用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ruby on Rails中创建个人博客.我想设计带有语法突出显示以及内联多个图片附件的单个帖子.我已经尝试过ckeditor gem和回形针,但是 redcarpet pygments.rb .

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 !!

推荐答案

Obtvse ,一个开源博客受 Svbtle 启发的引擎几乎可以完全满足您的需求.

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

它使用 Coderay 进行语法突出显示,这是一个纯粹的ruby库,不依赖javascript,并且降价(通过

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.

与基于JavaScript的解决方案相比,基于后端的语法突出显示在RSS阅读器中可以很好地发挥作用.

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.

或者,如果您特别倾向于使用CKEditor,则可以查看此插件,其中将CKEditor与 CodeMirror 集成在一起,后者是最流行的JavaScript代码编辑和突出显示解决方案之一.要显示代码段,您还可以按手册中所述以只读模式使用CodeMirror.这将确保您在编辑时以及在后视图页面中获得完全相同的语法突出显示.

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.

这篇关于在Rails中设计带有语法高亮和内嵌图像附件的博客文章有什么用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆