# Creating a custom filter

**URL:** <https://www.ruby-forum.com/t/creating-a-custom-filter/112906>\
**Category:** Radiant CMS\
**Created:** [August 24, 2007, 11:33am UTC](https://www.ruby-forum.com/t/creating-a-custom-filter/112906 "2007-08-24T11:33:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenngore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@glenngore](https://www.ruby-forum.com/u/glenngore)\
**Post date:** [August 24, 2007, 11:33am UTC](https://www.ruby-forum.com/t/creating-a-custom-filter/112906/1 "2007-08-24T11:33:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glenngore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/439d5e/32.png) [@glenngore](https://www.ruby-forum.com/u/glenngore)\
**Post date:** [August 24, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/creating-a-custom-filter/112906/2 "2007-08-24T15:30:55Z")

</div>

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](http://projects.danwebb.net/wiki/CodeHighlighter)

Hope this helps!

Sean
