Class: HParser::Block::ListItem

Inherits:
Object
  • Object
show all
Includes:
Hatena, Latex, Text
Defined in:
lib/hparser/block/list.rb,
lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/hatena.rb

Overview

This class undocumented. Maybe rewrite in near future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Text

#to_text

Constructor Details

#initialize(content) ⇒ ListItem

Returns a new instance of ListItem.



86
87
88
# File 'lib/hparser/block/list.rb', line 86

def initialize(content)
  @content = content
end

Instance Attribute Details

#contentObject (readonly) Also known as: latex_content, hatena_content

Returns the value of attribute content.



85
86
87
# File 'lib/hparser/block/list.rb', line 85

def content
  @content
end

Class Method Details

.make_parser(level, mark) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/hparser/block/list.rb', line 76

def self.make_parser(level,mark)
  include HParser::Util
  ProcParser.new{|scanner,context,inlines|
    if scanner.scan(/\A#{Regexp.quote mark*level}.*/) then
      ListItem.new inlines.parse(scanner.matched[level..-1].strip, context)
    end
  }
end

Instance Method Details

#==(o) ⇒ Object



90
91
92
# File 'lib/hparser/block/list.rb', line 90

def ==(o)
  o.class==self.class and o.content == self.content
end

#_to_hatena_Object



116
# File 'lib/hparser/hatena.rb', line 116

alias_method :_to_hatena_,:to_hatena

#text_contentObject



124
125
126
# File 'lib/hparser/text.rb', line 124

def text_content
  [HParser::Inline::Text.new(' '),self.content].flatten
end

#to_hatena(level, label) ⇒ Object



117
118
119
# File 'lib/hparser/hatena.rb', line 117

def to_hatena(level,label)
  label*level + _to_hatena_
end

#to_htmlObject



257
258
259
260
261
262
263
# File 'lib/hparser/html.rb', line 257

def to_html
  if content.class == Array then
    content.map{|x| x.to_html}.join
  else
    content
  end
end

#to_latexObject



207
208
209
210
# File 'lib/hparser/latex.rb', line 207

def to_latex
  content = super
  "  \\item #{content}\n"
end