#16 ✓resolved
James Adam

I want syntax highlighting

Reported by James Adam | June 5th, 2008 @ 10:03 PM | 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

    • Tag set to code, renderer, ruby, syntax
    • Milestone set to 0.6
  • 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 Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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

Pages