Class: Infoboxer::Parser

Inherits:
Object
  • Object
show all
Includes:
HTML, Image, Inline, Paragraphs, Template, Util, Tree
Defined in:
lib/infoboxer/parser.rb,
lib/infoboxer/parser/html.rb,
lib/infoboxer/parser/util.rb,
lib/infoboxer/parser/image.rb,
lib/infoboxer/parser/table.rb,
lib/infoboxer/parser/inline.rb,
lib/infoboxer/parser/context.rb,
lib/infoboxer/parser/template.rb,
lib/infoboxer/parser/paragraphs.rb

Defined Under Namespace

Modules: HTML, Image, Inline, Paragraphs, Table, Template, Util Classes: Context, ParsingError

Constant Summary

Constants included from Util

Util::FORMATTING, Util::INLINE_EOL, Util::INLINE_EOL_BRACK, Util::INLINE_EOL_BRACK2

Instance Attribute Summary

Attributes included from Util

#re

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Template

#template, #template_vars

Methods included from HTML

#html, #html_auto_closing_tag, #html_br, #html_closing_tag, #html_opening_tag

Methods included from Image

#image, #image_attr, #image_attrs

Methods included from Util

#guarded_loop, #make_regexps, #parse_params

Methods included from Paragraphs

#paragraphs

Methods included from Table

#table, #table_caption, #table_cell_cont, #table_cells, #table_next_line, #table_params, #table_row, #table_template

Methods included from Inline

#inline, #long_inline, #short_inline

Constructor Details

#initialize(context) ⇒ Parser

Returns a new instance of Parser.



53
54
55
56
# File 'lib/infoboxer/parser.rb', line 53

def initialize(context)
  @context = context
  @re = OpenStruct.new(make_regexps)
end

Class Method Details

.document(text, traits = nil) ⇒ Object



23
24
25
# File 'lib/infoboxer/parser.rb', line 23

def document(text, traits = nil)
  Tree::Document.new(paragraphs(text, traits))
end

.fragment(text, traits = nil) ⇒ Object



27
28
29
# File 'lib/infoboxer/parser.rb', line 27

def fragment(text, traits = nil)
  new(context(text, traits)).long_inline
end

.inline(text, traits = nil) ⇒ Object



11
12
13
# File 'lib/infoboxer/parser.rb', line 11

def inline(text, traits = nil)
  new(context(text, traits)).inline
end

.paragraph(text, traits = nil) ⇒ Object



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

def paragraph(text, traits = nil)
  paragraphs(text, traits).first
end

.paragraphs(text, traits = nil) ⇒ Object



15
16
17
# File 'lib/infoboxer/parser.rb', line 15

def paragraphs(text, traits = nil)
  new(context(text, traits)).paragraphs
end