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.



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

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



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

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

.fragment(text, traits = nil) ⇒ Object



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

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

.inline(text, traits = nil) ⇒ Object



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

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

.paragraph(text, traits = nil) ⇒ Object



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

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

.paragraphs(text, traits = nil) ⇒ Object



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

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