Class: SM::PreProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/markup/simple_markup/preprocess.rb

Overview

Handle common directives that can occur in a block of text:

: include : filename

Instance Method Summary collapse

Constructor Details

#initialize(input_file_name, include_path) ⇒ PreProcess

Returns a new instance of PreProcess.



11
12
13
14
# File 'lib/rdoc/markup/simple_markup/preprocess.rb', line 11

def initialize(input_file_name, include_path)
  @input_file_name = input_file_name
  @include_path = include_path
end

Instance Method Details

#handle(text) ⇒ Object

Look for common options in a chunk of text. Options that we don't handle are passed back to our caller as |directive, param|



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rdoc/markup/simple_markup/preprocess.rb', line 20

def handle(text)
  text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do 
    prefix    = $1
    directive = $2.downcase
    param     = $3

    case directive
    when "include"
      filename = param.split[0]
      include_file(filename, prefix)

    else
      yield(directive, param)
    end
  end
end