#16 √ resolved
James Adam

I want syntax highlighting

Reported by James Adam | June 5th, 2008 @ 12:15 AM | in 0.6

Maybe we could have a 'code' renderer, using the Syntax gem or something, that renders snips with syntax highlighting.

The language the snip is written in could be an attribute of the snip?

Comments and changes to this ticket

  • James Adam

    James Adam July 2nd, 2008 @ 09:40 PM

    • → Milestone changed from “” to “0.6”
    • → Tag changed from “” to “code renderer ruby syntax”
  • James Adam

    James Adam July 17th, 2008 @ 05:48 PM

    • → State changed from “new” to “resolved”

    Kindof works now, thanks to a hackety dyna:

    require 'syntax/convertors/html'
    class CodeHighlighter < Dynasnip
      def handle(language, snip_to_render, part_to_render='content')
        snip = Vanilla.snip(snip_to_render)
        text = snip.__send__(part_to_render.to_sym)
        convertor = Syntax::Convertors::HTML.for_syntax(language)
        code = convertor.convert(text, false)
        %(<pre class="code ) + language + %("><code>) + code + %(</code></pre>)
      end
    
      self
    end
    

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

A sort of meta-wiki thing

People watching this ticket