Forum: Radiant CMS best code syntax highlighting solution

Posted by John Doe (craayzie)
on 2010-12-08 08:40
(Received via mailing list)
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 :P

I found 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
Posted by John Muhl (johnmuhl)
on 2010-12-08 16:03
(Received via mailing list)
On Wed, Dec 8, 2010 at 1:39 AM, craayzie <fleshins@gmail.com> 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.
Posted by John Doe (craayzie)
on 2010-12-08 19:38
(Received via mailing list)
Thanks John - will take a look. Do you have any public pages you can 
share
as examples?
Posted by John Muhl (johnmuhl)
on 2010-12-08 21:50
(Received via mailing list)
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/ list the supported languages.
Posted by John Doe (craayzie)
on 2010-12-12 23:51
(Received via mailing list)
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.
Posted by John Doe (craayzie)
on 2010-12-12 23:59
(Received via mailing list)
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? :P

Thanks again.
Posted by John Doe (craayzie)
on 2010-12-13 00:07
(Received via mailing list)
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

now just need to figure out how to leverage the coderay gem :P
Posted by John Doe (craayzie)
on 2010-12-13 00:24
(Received via mailing list)
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/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?

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

Thanks!
Posted by John Muhl (johnmuhl)
on 2010-12-13 04:28
(Received via mailing list)
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.
Posted by Kevin Triplett (mopacmedia)
on 2010-12-13 08:17
John Doe wrote in post #967984:
> 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/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
Posted by John Doe (craayzie)
on 2010-12-13 15:57
(Received via mailing list)
Looks like coderay is working well. I installed:

coderay gem + radiant extension @ 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
Posted by John Muhl (johnmuhl)
on 2010-12-13 16:02
(Received via mailing list)
On Mon, Dec 13, 2010 at 8:56 AM, Fima Leshinsky <fleshins@gmail.com> 
wrote:
> Looks like coderay is working well. I installed:
> coderay gem + radiant extension @ 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.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.