Class: Tipi::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/tipi/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, options = {}) ⇒ Parser

Returns a new instance of Parser.



12
13
14
15
16
17
# File 'lib/tipi/parser.rb', line 12

def initialize(text, options = {})
  @allowed_schemes = %w(http https ftp ftps)
  @text            = text
  @extensions = @no_escape = nil
  options.each_pair {|k,v| send("#{k}=", v) }
end

Instance Attribute Details

#allowed_schemesObject

Returns the value of attribute allowed_schemes.



6
7
8
# File 'lib/tipi/parser.rb', line 6

def allowed_schemes
  @allowed_schemes
end

#extensions=(value) ⇒ Object (writeonly)

Sets the attribute extensions

Parameters:

  • value

    the value to set the attribute extensions to.



7
8
9
# File 'lib/tipi/parser.rb', line 7

def extensions=(value)
  @extensions = value
end

#no_escape=(value) ⇒ Object (writeonly)

Sets the attribute no_escape

Parameters:

  • value

    the value to set the attribute no_escape to.



9
10
11
# File 'lib/tipi/parser.rb', line 9

def no_escape=(value)
  @no_escape = value
end

Instance Method Details

#extensions?Boolean

Returns:

  • (Boolean)


8
# File 'lib/tipi/parser.rb', line 8

def extensions?; @extensions; end

#no_escape?Boolean

Returns:

  • (Boolean)


10
# File 'lib/tipi/parser.rb', line 10

def no_escape?; @no_escape; end

#to_htmlObject



19
20
21
22
23
24
25
# File 'lib/tipi/parser.rb', line 19

def to_html
  @out = ''
  @p = false
  @stack = []
  parse_block(@text)
  @out
end