Class: HParser::Inline::Text

Inherits:
Object
  • Object
show all
Includes:
Collectable
Defined in:
lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/hatena.rb,
lib/hparser/inline/text.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Text

Returns a new instance of Text.



23
24
25
# File 'lib/hparser/inline/text.rb', line 23

def initialize(text)
  @text = text
end

Instance Attribute Details

#textObject (readonly) Also known as: to_text, to_hatena

Returns the value of attribute text.



10
11
12
# File 'lib/hparser/inline/text.rb', line 10

def text
  @text
end

Class Method Details

.<=>(o) ⇒ Object



12
13
14
15
# File 'lib/hparser/inline/text.rb', line 12

def self.<=>(o)
  # This parser should be last.
  1
end

.parse(scanner, context = nil) ⇒ Object



17
18
19
20
21
# File 'lib/hparser/inline/text.rb', line 17

def self.parse(scanner, context=nil)
  if scanner.scan(%r!<(a|iframe|script).*?</\1>!) or scanner.scan(%r!<img\s.*?>!) or scanner.scan(/./m)
    Text.new(scanner.matched)
  end
end

Instance Method Details

#+(other) ⇒ Object



27
28
29
# File 'lib/hparser/inline/text.rb', line 27

def +(other)
  Text.new(self.text+other.text)
end

#==(o) ⇒ Object



31
32
33
# File 'lib/hparser/inline/text.rb', line 31

def ==(o)
  o.class == self.class and @text == o.text
end

#to_htmlObject



287
288
289
# File 'lib/hparser/html.rb', line 287

def to_html
  self.text
end

#to_latexObject



230
231
232
# File 'lib/hparser/latex.rb', line 230

def to_latex
  self.text
end