Class: HParser::Block::Dl
- Inherits:
-
Object
- Object
- HParser::Block::Dl
- Includes:
- Collectable, Html, Latex
- Defined in:
- lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/block/dl.rb
Defined Under Namespace
Classes: Item
Constant Summary
Constants included from Html
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
- #html_content ⇒ Object
- #html_tag ⇒ Object
-
#initialize(*items) ⇒ Dl
constructor
A new instance of Dl.
- #latex_content ⇒ Object
- #to_latex ⇒ Object
- #to_text ⇒ Object
Methods included from Html
Constructor Details
#initialize(*items) ⇒ Dl
Returns a new instance of Dl.
36 37 38 |
# File 'lib/hparser/block/dl.rb', line 36 def initialize(*items) @items = items end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
35 36 37 |
# File 'lib/hparser/block/dl.rb', line 35 def items @items end |
Class Method Details
.parse(scanner, context, inlines) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hparser/block/dl.rb', line 24 def self.parse(scanner,context,inlines) items = [] while scanner.scan(/\A:((?:<[^>]+>|\[[^\]]+\]|[^:])+):(.+)/) i = scanner.matched.index(':',1) title = inlines.parse scanner.matched_pattern[1], context description = inlines.parse scanner.matched_pattern[2], context items.push Item.new(title,description) end items == [] ? nil : self.new(*items) end |
Instance Method Details
#==(o) ⇒ Object
40 41 42 |
# File 'lib/hparser/block/dl.rb', line 40 def ==(o) o.class == self.class and o.items == self.items end |
#html_content ⇒ Object
218 219 220 |
# File 'lib/hparser/html.rb', line 218 def html_content @items end |
#html_tag ⇒ Object
214 215 216 |
# File 'lib/hparser/html.rb', line 214 def html_tag() 'dl' end |
#latex_content ⇒ Object
155 156 157 |
# File 'lib/hparser/latex.rb', line 155 def latex_content @items end |
#to_latex ⇒ Object
150 151 152 153 |
# File 'lib/hparser/latex.rb', line 150 def to_latex content = super %Q[\\begin{description}\n#{content}\n\\end{description}\n] end |
#to_text ⇒ Object
106 107 108 |
# File 'lib/hparser/text.rb', line 106 def to_text @items.map{|x| x.to_text}.join("\n") end |