class WikiCloth::Parser

Public Class Methods

cache(&block) click to toggle source
# File lib/wikicloth/parser.rb, line 80
def cache(&block)
  self.send :define_method, 'cache' do |item|
    self.instance_exec(item,&block)
  end
end
function(&block) click to toggle source
# File lib/wikicloth/parser.rb, line 30
def function(&block)
  self.send :define_method, 'function' do |name, params|
    self.instance_exec(name, params, &block)
  end
end
include_resource(&block) click to toggle source
# File lib/wikicloth/parser.rb, line 42
def include_resource(&block)
  self.send :define_method, 'include_resource' do |resource,options|
    options ||= []
    self.instance_exec(resource,options,&block)
  end
end
new(options={}) click to toggle source
# File lib/wikicloth/parser.rb, line 5
def initialize(options={})
  options.each { |k,v|
    if v.instance_of?(Proc)
      self.class.send :define_method, k.to_sym do |*args|
        self.instance_exec(args,&v)
      end
    end
  }
  @options = { :link_handler => self, :params => {} }.merge(options)
  @wikicloth = WikiCloth.new(@options)
end
template(&block) click to toggle source
# File lib/wikicloth/parser.rb, line 49
def template(&block)
  self.send :define_method, 'template' do |template|
    self.instance_exec(template,&block)
  end
end
toc(&block) click to toggle source
# File lib/wikicloth/parser.rb, line 24
def toc(&block)
  self.send :define_method, 'toc' do |sections, numbered|
    self.instance_exec(sections, numbered, &block)
  end
end
url_for(&block) click to toggle source
# File lib/wikicloth/parser.rb, line 18
def url_for(&block)
  self.send :define_method, 'url_for' do |url|
    self.instance_exec(url, &block)
  end
end

Public Instance Methods

get_section(id) click to toggle source

Get the section, along with any sub-section of the document

# File lib/wikicloth/parser.rb, line 102
def get_section(id)
  @wikicloth.sections.collect { |s| s.get_section(id) }.join
end
method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/wikicloth/parser.rb, line 87
def method_missing(method, *args)
  if @wikicloth.respond_to?(method)
    @wikicloth.send(method, *args)
  else
    super(method, *args)
  end
end
put_section(id,data) click to toggle source

Replace a section, along with any sub-section in the document

# File lib/wikicloth/parser.rb, line 96
def put_section(id,data)
  data = @wikicloth.sections.collect { |s| s.wikitext({ :replace => { id => data.last(1) == "\n" ? data : "#{data}\n" } }) }.join
  @wikicloth = WikiCloth.new(:data => data, :link_handler => self, :params => @options[:params])
end
to_wiki() click to toggle source
# File lib/wikicloth/parser.rb, line 106
def to_wiki
  to_wikitext
end
to_wikitext() click to toggle source
# File lib/wikicloth/parser.rb, line 110
def to_wikitext
  @wikicloth.sections.collect { |s| s.wikitext() }.join
end