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

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

.format_nameObject


19
20
21
# File 'lib/rabbit/parser/wiki.rb', line 19

def format_name
  "Wiki"
end

.match?(source) ⇒ Boolean

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rabbit/parser/wiki.rb', line 23

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


38
39
40
41
42
# File 'lib/rabbit/parser/wiki.rb', line 38

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