Class: HParser::Inline::Footnote
- Inherits:
-
Object
- Object
- HParser::Inline::Footnote
- Includes:
- Collectable
- Defined in:
- lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/inline/footnote.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(index, text) ⇒ Footnote
constructor
A new instance of Footnote.
- #to_html ⇒ Object
- #to_latex ⇒ Object
- #to_text ⇒ Object
Constructor Details
#initialize(index, text) ⇒ Footnote
Returns a new instance of Footnote.
12 13 14 15 |
# File 'lib/hparser/inline/footnote.rb', line 12 def initialize(index, text) @index = index @text = text end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
11 12 13 |
# File 'lib/hparser/inline/footnote.rb', line 11 def index @index end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
11 12 13 |
# File 'lib/hparser/inline/footnote.rb', line 11 def text @text end |
Class Method Details
.parse(scanner, context) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hparser/inline/footnote.rb', line 17 def self.parse(scanner, context) if scanner.scan(/\)\(\(.+?\)\)\(/) then # )((xxx))( -> ((xxx)) Text.new scanner[0][1..-2] elsif scanner.scan(/\(\((.+?)\)\)/) then index = context.footnotes.length + 1 f = Footnote.new index, scanner[0][2..-3] context.footnotes << f f end end |
Instance Method Details
#==(o) ⇒ Object
29 30 31 |
# File 'lib/hparser/inline/footnote.rb', line 29 def ==(o) self.class == o.class and @index == o.index and @text == o.text end |
#to_html ⇒ Object
325 326 327 328 |
# File 'lib/hparser/html.rb', line 325 def to_html text = self.text.gsub(/<.*?>/, '') %(<span class="footnote"><a href="#f#{self.index}" title="#{text}" name="fn#{self.index}">*#{self.index}</a></span>) end |
#to_latex ⇒ Object
260 261 262 |
# File 'lib/hparser/latex.rb', line 260 def to_latex %(\\footnote{#{self.text}}) end |
#to_text ⇒ Object
168 169 170 |
# File 'lib/hparser/text.rb', line 168 def to_text "(*#{self.index})" end |