Class: Rabbit::Parser::Wiki

Inherits:
Base
  • Object
show all
Includes:
Element
Defined in:
lib/rabbit/parser/wiki.rb,
lib/rabbit/parser/wiki.rb,
lib/rabbit/parser/wiki/output.rb

Defined Under Namespace

Classes: RabbitOutput

Constant Summary

Constants included from ModuleLoader

ModuleLoader::LOADERS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, name

Methods included from ModuleLoader

extend_object, #find_loader, #loaders, #push_loader, #unshift_loader

Constructor Details

This class inherits a constructor from Rabbit::Parser::Base

Class Method Details

.match?(source) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rabbit/parser/wiki.rb', line 19

def match?(source)
  extension = source.extension
  if extension.nil?
    head = source.read[0, 500]
    if head.respond_to?(:force_encoding)
      head.force_encoding("ASCII-8BIT")
    end
    /^!/.match(head)
  else
    /\A(?:hiki|wiki)\z/i =~ extension
  end
end

Instance Method Details

#parseObject



34
35
36
37
38
# File 'lib/rabbit/parser/wiki.rb', line 34

def parse
  parser = HikiDoc.new(RabbitOutput.new(@canvas),
                       :use_wiki_name => false)
  parser.compile(@source.read)
end