0

I am building a Rails 4 app, where I want users to be able to read/write/upload/download files with different kind of files with color highlighting depending on the programming language of the file. Currently I've found a few gems which allow you to read a file and display with color highlighting, just like sublime or any other rich text editor.

I haven't found any text-editor which allows you to choose a language, and based on that highlight the words depending on the language chosen.

I'm looking for something like the editor gistbox has, but haven't found anything yet. Here's an example of what I'm trying to get. enter image description here

4

2 回答 2

2

你看过Github 使用的 gem吗?这可能正是你想要的。

如果没有,则可以使用像highlight之类的 gem并通过 jquery 使用刷新来生成带有突出显示文本的 div,甚至可能在 textarea 内 - 这可能有点棘手,但应该是可能的 -

于 2013-11-07T22:46:22.007 回答
0

最后我给 gisthub 的创建者发了一封邮件,信息如下:

要读取文件并以任何语言获得漂亮的视图,请使用以下命令:highlightJS

要拥有一个识别不同类型语言的好编辑器,请使用ace

于 2013-11-09T02:07:43.787 回答