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

#sanitize_value, #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.



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

def initialize(context)
  @context = context
  @re = OpenStruct.new(make_regexps)
  @logger = Logger.new($stdout).tap { |l| l.level = Logger::FATAL }
end

Class Method Details

.document(text, traits = nil) ⇒ Object



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

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

.fragment(text, traits = nil) ⇒ Object



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

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

.inline(text, traits = nil) ⇒ Object



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

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

.paragraph(text, traits = nil) ⇒ Object



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

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

.paragraphs(text, traits = nil) ⇒ Object



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

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