Class: Heading
- Defined in:
- lib/almirah/doc_items/heading.rb
Instance Attribute Summary collapse
-
#anchor_id ⇒ Object
Returns the value of attribute anchor_id.
-
#level ⇒ Object
Returns the value of attribute level.
Attributes inherited from Paragraph
Attributes inherited from DocItem
Instance Method Summary collapse
-
#initialize(text, level) ⇒ Heading
constructor
A new instance of Heading.
- #to_html ⇒ Object
Methods inherited from Paragraph
Methods inherited from TextLine
add_lazy_doc_id, #bold, #bold_and_italic, #change_state, #format_string, #italic, #link
Constructor Details
#initialize(text, level) ⇒ Heading
Returns a new instance of Heading.
8 9 10 11 12 |
# File 'lib/almirah/doc_items/heading.rb', line 8 def initialize(text, level) @text = text @level = level @anchor_id = getTextWithoutSpaces() end |
Instance Attribute Details
#anchor_id ⇒ Object
Returns the value of attribute anchor_id.
6 7 8 |
# File 'lib/almirah/doc_items/heading.rb', line 6 def anchor_id @anchor_id end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/almirah/doc_items/heading.rb', line 5 def level @level end |
Instance Method Details
#to_html ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/almirah/doc_items/heading.rb', line 14 def to_html s = '' if @@htmlTableRenderInProgress s += "</table>\n" @@htmlTableRenderInProgress = false end headingLevel = level.to_s s += "<a name=\"#{@anchor_id}\"></a>\n" s += "<h#{headingLevel}> #{@text} <a href=\"\##{@anchor_id}\" class=\"heading_anchor\">" s += "¶</a></h#{headingLevel}>" return s end |