Creating a custom filter

Morning all,

Is anybody able to point me in the right direction to a tutorial,
guide, or just the existing code for creating and adding to the
available filters? I want to change the support for highlighting
blocks for my own purposes, and I gather this is what
I’m going to need to do.

Thanks,

Glenn

That wholly depends on which approach you want to take… filter the
whole part, just process a piece of it, or do it after the fact.

If you want to filter the whole part, take a look at the built-in
Markdown and Textile filters. They take a very simple approach, which
is to take the rendered text and pass it directly to an external engine
(The Sass filter takes this approach too).

If you want to process just a piece, the approach would be to write a
global tag that does the filtering for you. This is the approach of the
original Syntax Highlighting behavior in 0.5.x, which provided an
<r:code/> tag, within which you would place your code.

There are also a number of Javascript libraries that can do syntax
highlighting on the client side. They’re perhaps not as robust as a
server-side version, but in many cases they do exactly what you need.
Dan W. has one: http://projects.danwebb.net/wiki/CodeHighlighter

Hope this helps!

Sean

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs