[Nitro] getting spark to hightlight syntax...

manveru ulmo at valaraan.de
Mon Sep 5 19:07:50 EDT 2005

hi list,

i've been wasting the last hours trying to find out how the spark-pages 
get rendered...
my goal was simple enough - getting text between [code]-tags parsed 
through coderay like that:

"[code] this is some code [/code]".gsub(/\[code\](.*)\[\/code\]/) { |c|
    c = CodeRay.scan(c, 'ruby').encode(:html, :bold_every => 10, :wrap 
=> :div)
should give me something like

<div class="code">
    <table class="code_table">
            <td class="code_cell"><div class="nowrap"><pre>This is some 
so i've put the following lines into the WikiController.view

body = @page.body.gsub(' ', ' ')
@page.body = body.gsub(/\[code\](.*)\[\/code\]/) { |c|
  c.gsub!('[code]', '')
  c.gsub!('[/code]', '')
  c = CodeRay.scan(c, 'ruby').encode(:html, :bold_every => 10, :wrap => 

you may notice how absurd these lines are... especially the first, but 
trying to gsub without that causes a nil-exception...

well, it works almost for one-liners, redcloth is destroying the markup 
coderay produces anyway.
now i could kick out redcloth, but that seems as the worst solution to 
get syntax-highlighting.
is there some way to either:
*define an area redcloth doesn't process
*hack redcloth from within the nitro-app and tell him to do that gsub
*get the redcloth-parsing optional in the skin
*change that 'Markup.setup_markup_transform do |text|' so it doesn't 
iterate through lines and instead takes the whole text - this may cause 
severe problems with redcloth...
*something else i haven't thought about

i just want to highlight that code... can't be that hard after all...

btw, i know my regexp is wrong - haven't spent too much time finding out 
how to match linebrakes...

i am really greatful for any help

so long...

More information about the Nitro-general mailing list