How to add Rich Text Editor to display code snippets - javascript

Im working on a Rails based application where I have the need to allow the user to format the text he enters and I would also like a way to highlight code snippets the way Stackoverflow does when I enter a code snippet.
Are there any plugins that do this.
And I would also like to know which is the RTE that is recommended and would be unobtrusive.
I see a lot of recommendations for FCKEditor but how do I implement the code snippets?

It seems like you might need something lighterweight than CKeditor. If you do choose to use CKeditor, I would use a rails plugin to install it. I use this one :
http://github.com/galetahub/rails-ckeditor
The directions are very straightforward on the git.
As for Syntax Highlighting , I recommend :
The GitHub crew loves Pygments. They are using it on many different places, including Jekyll and GitHub itself. The downside is that it's a python library so you would need to install python and execute it as a shell task.
Syntax Highlighter, jQuery Library <-- The easiest to implement
http://alexgorbatchev.com/SyntaxHighlighter/
Rails3 has these plugins :
Ruby offers 3 code highlighting Gems: Ultraviolet, Syntax and CodeRay. AFAIK, the last one is the most adopted.

Related

What is the formatter/syntax highlighter to work with ejs (embedded javascript) templates?

For the project I use EJS (http://ejs.co/) as express templating engine. It is good and easy to use, but editing files is a bit of a problem - text highlight is worse than average and I could not find any tools to auto format files.
My main IDE is VS Code and I have tried Atom.
For VS code I used QassimFarid.ejs-language-support, which has way more installs than all others and I found it lacking. Tried DigitalBrainstem.javascript-ejs-support, but it is getting confused with my code pretty soon too.
For Atom I go with language-ejs (atom.io/packages/language-ejs) which is very good.
Sadly, both VS Code and Atom do not have any autoformat capabilities (read packages), and pure JS formatters are confused with ejs markup.
What do you use to format your ejs templates?
P.S.
I do not mind trying some other IDEs/editors or even some standalone formatters.
Your question is quite subjective, so I can't really offer a definitive answer. But I get the feeling you're just using the base text editor rather than installing packages.
Both VS Code and Atom come with package systems. In VS Code you can click on the "Extensions" icon on the left hand panel (under the debug item). This will let you search for extensions that offer things such as auto-complete and syntax highlighting. Just by typing in "ejs" there are 4 different syntax highlighting and evaluators.
Atom also has a similar system to search for and install packages. From here you should be able to find one which suits your needs for EJS.

How to use localizations in SCEditor? (and general feedback & experiences)

I'm currently evaluating javascript based BBCode editors for a project.
The SCEditor seems to be realy great and got a lot of usefull features.
But can anyone tell me how to use the localizations? I could not find any localization files so I don't know if there are any prebuild languages existing or if i have to create them for my own, and in this case, how they have to look like.
I also could not find any documentation for this, there is just this hint the documentation.
And in general:
How are your experiances with this editor? And are there any other suggestions i maybe should have a look at?
In order to use the localization, that is actually all you need to do. Just include the correct .js localization file and that will be the localization that SCEditor will use for that webpage.
Have you tried doing that?

Recommendation for SWT/JFace Javascript Editor?

I'm building an app using SWT + JFace and I would like to integrate a Javascript editor (with Syntax Highlighting and Auto-Indent).
I'm looking for something simple like RSyntaxTextArea: just use the widget like as a TextArea and set the syntax to "Javascript".
So far I've come across examples with "JFace Text" but it seems I have to implement the Javascript part myself. Also, I don't want to integrate the whole Eclipse workbench if possible.
Do you know of any component that would do the job?
It's possible to use StyledText widget (so no dependency on JFace) to show syntax highlight (see Into the Deep End of the SWT StyledText Widget), but it's quite lot of work to do..
For additional example see Implements syntax coloring using the StyledText API.
It's also possible to use SWT_AWT bridge and put the RSyntaxTextArea to your application directly..
I found some interesting project, which might help you with the situation..
It's called The DJ Project (The Sweet library brings some rich components to SWT-based applications) and when you check the Gallery, you can find as last example SWT gui with javascript syntax highlighted text area.
The licence is LGPL, which is one of the best for any purpose..

Which library does GitHub use to beautify JavaScript code?

Which library does GitHub use to beautify JavaScript code?
I am looking for a good code prettify library.
http://help.github.com/troubleshooting-common-issues/
We use the excellent pygments library for our syntax highlighting. Check their list of supported languages and learn how to specify a lexer for yours. If you contribute a lexer back to pygments, let us know and we’ll make sure it’s made available here on GitHub.
Github do not appear to use any client side library to render code. You can see, using something like Chrome's Net tab, that the HTML views of code arrive from the server prewrapped with vast numbers of span elements.

What is a good javascript editor for editing custom DSL code?

I'm looking for a nice / customisable editor to put on a web page for editing scripts for a custom DSL. Ideally with syntax highlighting (and intellisense would be great! )
Anyone know of anything suitable?
For syntax highlighting, look at EditArea. Intellisense could be written as a plugin.
maybe you should have a look at codemirror:
http://codemirror.net/
it's "just" an editor-component and you will probably have to put some work into it. but it's easy to enhance and integrate it.
You should take a look at Bespin. You have a good description here:
http:// mozillalabs.com/bespin/2010/01/15/bespin-embedded-0-6-released-now-in-two-great-flavors/
It has a full support for being embedded. See the embedding doc :
https:// bespin.mozilla.com/docs/embedding/index.html
You can write a custom syntax highlighting plugin pretty easily if needed.
You can probably fork and adapt one of the built-in syntax highlighters.
The editor itself and its plugins are written in Javascript.
The project is aimed at being a complete web-based & collaborative code editor, so intellisense-like features should make their way in soon if they're no alreay present.
The successor of the Mozilla Skywriter (Bespin) project is ACE: http://ace.ajax.org/

Categories