Baseclass from which Rote filters can be derived if they want to process text without macros. This class replaces macro tags/bodies with simple placeholders, containing only characters [a-z0-9] before passing it the text to the block. On return, macro markers are replaced with the corresponding (numbered) original macro body.

Methods
Attributes
[RW] handler_blk
[RW] macros
Public Class methods
new(&handler)

Create a new TextFilter. The supplied block will be called with the text to be rendered, with all macros replaced by plain-text macro markers:

  { |text, page| "replacement" }
    # File lib/rote/filters/base.rb, line 37
37:       def initialize(&handler)
38:         @handler_blk = handler
39:         @macros = []
40:       end
Public Instance methods
filter(text, page)
    # File lib/rote/filters/base.rb, line 42
42:       def filter(text, page)
43:         # we need to remove any macros to stop them being touched
44:         n = -1        
45:         tmp = text.gsub(MACRO_RE) do
46:           macros << $&
47:           # we need make the marker a 'paragraph'
48:           "\nxmxmxmacro#{n += 1}orcamxmxmx\n"
49:         end
50:         
51:         tmp = handler(tmp,page)
52:       
53:         # Match the placeholder, including any (and greedily all) markup that's
54:         # been placed before or after it, and put the macro text back.
55:         tmp.gsub(PLACEHOLDER_RE) { macros[$1.to_i] }      
56:       end
Protected Instance methods
handler(tmp,page)

Calls the handler block. Subclasses may override this rather than use a block.

    # File lib/rote/filters/base.rb, line 62
62:       def handler(tmp,page)
63:         handler_blk[tmp,page] if handler_blk
64:       end