# Best code syntax highlighting solution

**URL:** <https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274>\
**Category:** Radiant CMS\
**Created:** [December 8, 2010, 8:40am UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274 "2010-12-08T08:40:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 8, 2010, 8:40am UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/1 "2010-12-08T08:40:17Z")

</div>

I’ve begun to explore Radiant as a publishing/blogging platform. At  
the moment, I’m trying to nail down is how to best format command-line  
output or code as the majority of the content published will be of a  
technical nature.

Can someone point me in the right direction of what I should use to  
get the “desired” affect 😛

I found [Background Photos 100% For Free to Download | Wallpapers.com](http://alexgorbatchev.com/SyntaxHighlighter/) which is a  
JavaScript-based solution. Unfortunately it doesn’t appear to support  
formatting/highlighting command-line output.

What’s the best Radiant filter / JS library / some-other-solution out  
there for both command-line output and code syntax highlighting?

Thanks in advance!

Fima

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 8, 2010, 4:03pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/2 "2010-12-08T16:03:39Z")

</div>

On Wed, Dec 8, 2010 at 1:39 AM, craayzie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> formatting/highlighting command-line output.
> 
> What’s the best Radiant filter / JS library / some-other-solution out  
> there for both command-line output and code syntax highlighting?

i like kramdown + coderay.

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 8, 2010, 7:38pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/3 "2010-12-08T19:38:08Z")

</div>

Thanks John - will take a look. Do you have any public pages you can  
share  
as examples?

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 8, 2010, 9:50pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/4 "2010-12-08T21:50:43Z")

</div>

[http://johnmuhl.com/tmp/kramdown-coderay](http://johnmuhl.com/tmp/kramdown-coderay)

the kramdown looks like (replace - with space):

----def meth options  
------p options  
----end  
{:lang=“ruby”}

just a standard markdown code block followed by {:lang=“lang”}

[http://coderay.rubychan.de/](http://coderay.rubychan.de/) list the supported languages.

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 12, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/5 "2010-12-12T23:59:31Z")

</div>

Ok, so I’m sure you can tell by this last post of mine that I’m a  
complete noob. Looks like it’s kramdown that I would use for the  
markdown and then coderay for syntax highlighting. Fine. Figured out  
that part. So now the question is how do I use kramdown + coderay w/  
radiant? 😛

Thanks again.

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 13, 2010, 12:07am UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/6 "2010-12-13T00:07:05Z")

</div>

don’t mind me - I’m just going to update this thread as I figure more  
things  
out … looks like there’s a kramdown radiant filter 🙂  
[http://ext.radiantcms.org/extensions/192-kramdown-filter](http://ext.radiantcms.org/extensions/192-kramdown-filter)

now just need to figure out how to leverage the coderay gem 😛

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 12, 2010, 11:51pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/7 "2010-12-12T23:51:59Z")

</div>

I can’t quite figure out how to use the coderay gem. Could you provide  
some guidance around how to do it? I see that there are filters  
available to me via extensions that allow me to leverage different  
text markups - I’m guessing I’d have to use the coderay gem in a  
different manner? Or should it be exposed as a filter like the others?

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 13, 2010, 12:24am UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/8 "2010-12-13T00:24:39Z")

</div>

So looks like there are two radiant extensions below that allow you to  
leverage the coderay gem:  
[https://github.com/phallstrom/code\_ray](https://github.com/phallstrom/code_ray)

> **[GitHub - alno/radiant-code-extension: Extension to highlight code in Radiant CMS](https://github.com/alno/radiant-code-extension)**
>
> Extension to highlight code in Radiant CMS. Contribute to alno/radiant-code-extension development by creating an account on GitHub.

I’m inclined to use the the 2nd one since it supports other syntax  
highlighters beyond coderay. What are your thoughts on which one to use?

Also, I’m curious, why use kramdown over the existing Markdown radiant  
filter? Speed or other reasons as well?

Thanks!

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 13, 2010, 8:17am UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/9 "2010-12-13T08:17:20Z")

</div>

John D. wrote in post #967984:

> So looks like there are two radiant extensions below that allow you to  
> leverage the coderay gem:  
> [GitHub - phallstrom/code\_ray: A RadiantCMS extension to provide syntax highlighting via the CodeRay ruby gem · GitHub](https://github.com/phallstrom/code_ray)  
> [GitHub - alno/radiant-code-extension: Extension to highlight code in Radiant CMS · GitHub](https://github.com/alno/radiant-code-extension)
> 
> I’m inclined to use the the 2nd one since it supports other syntax  
> highlighters beyond coderay. What are your thoughts on which one to use?

I tried to use alno/radiant-code-extension for the same reason but had  
to switch over to phallstrom/code\_ray because I couldn’t overcome an  
processor error and I decided that coderay was an acceptably easy  
library to implement and use.

Ultimately, I forked it so I could merge envygeek’s fork and  
pallstrom’s.

Kevin

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 13, 2010, 3:57pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/10 "2010-12-13T15:57:07Z")

</div>

Looks like coderay is working well. I installed:

coderay gem + radiant extension @ [GitHub - phallstrom/code\_ray: A RadiantCMS extension to provide syntax highlighting via the CodeRay ruby gem](https://github.com/phallstrom/code_ray)

and now I can specify \<r:code\> blocks!

not sure what the benefits are of kramdown over the existing Markdown  
radiant filter that comes with the “Coffee blog” template. If you guys  
can  
shed some light on why kramdown is a better option I’d appreciate it.

Thanks again!  
Fima

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 13, 2010, 4:28am UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/11 "2010-12-13T04:28:00Z")

</div>

gem install radiant-kramdown\_filter-extension  
gem install coderay

then in config/environment.rb

…  
require ‘radius’  
require ‘coderay’ # add this line  
…  
config.gem ‘will\_paginate’, :version =\> ‘~\> 2.3.11’  
config.gem ‘radiant-kramdown\_filter-extension’ # add this line  
…

then restart radiant and you should be all set.

---

<div class="post-metadata">

**Author:** ![craayzie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e47774/32.png) [@craayzie](https://www.ruby-forum.com/u/craayzie)\
**Post date:** [December 13, 2010, 4:02pm UTC](https://www.ruby-forum.com/t/best-code-syntax-highlighting-solution/200274/12 "2010-12-13T16:02:08Z")

</div>

On Mon, Dec 13, 2010 at 8:56 AM, Fima L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Looks like coderay is working well. I installed:  
> coderay gem + radiant extension @ [GitHub - phallstrom/code\_ray: A RadiantCMS extension to provide syntax highlighting via the CodeRay ruby gem · GitHub](https://github.com/phallstrom/code_ray)  
> and now I can specify \<r:code\> blocks!  
> not sure what the benefits are of kramdown over the existing Markdown  
> radiant filter that comes with the “Coffee blog” template. If you guys can  
> shed some light on why kramdown is a better option I’d appreciate it.

it’s not better. it’s the same but with kramdown specific options  
enabled.
