Class: Rabbit::Parser::RD
- Defined in:
- lib/rabbit/parser/rd.rb,
lib/rabbit/parser/rd.rb,
lib/rabbit/parser/rd/visitor.rb,
lib/rabbit/parser/rd/ext/base.rb,
lib/rabbit/parser/rd/ext/image.rb,
lib/rabbit/parser/rd/ext/refer.rb,
lib/rabbit/parser/rd/ext/video.rb,
lib/rabbit/parser/rd/rd2rabbit-lib.rb,
lib/rabbit/parser/rd/rd2rabbit-lib.rb,
lib/rabbit/parser/rd/ext/block-verbatim.rb,
lib/rabbit/parser/rd/ext/inline-verbatim.rb,
lib/rabbit/parser/rd/ext/character-reference.rb
Defined Under Namespace
Modules: Ext, NoURLMark Classes: RD2RabbitVisitor, Visitor
Constant Summary
Constants included from ModuleLoader
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
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_name ⇒ Object
19 20 21 |
# File 'lib/rabbit/parser/rd.rb', line 19 def format_name "RD" end |
.match?(source) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rabbit/parser/rd.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 /^=(?:\s+\S|[^=])/ === head else /\A(?:rd|rab|rbt)\z/i =~ extension end end |
Instance Method Details
#parse ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rabbit/parser/rd.rb', line 37 def parse source = @source.read.gsub(/\r\n/, "\n") source = "=begin\n#{source}\n=end\n" tree = ::RD::RDTree.new(source) visitor = RD2RabbitVisitor.new(@canvas, @progress) visitor.visit(tree) rescue Racc::ParseError = ($!., source) raise ParseError.new, , $@ end |