Class: Elisp::Heading

Inherits:
Object
  • Object
show all
Defined in:
lib/elisp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, level: 2) ⇒ Heading



55
56
57
58
# File 'lib/elisp.rb', line 55

def initialize(content, level: 2)
  @content = content
  @level = level
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



53
54
55
# File 'lib/elisp.rb', line 53

def content
  @content
end

#levelObject (readonly)

Returns the value of attribute level.



53
54
55
# File 'lib/elisp.rb', line 53

def level
  @level
end

Instance Method Details

#htmlObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/elisp.rb', line 60

def html
  name = "h#{@level}"
  content = CGI.escape_html(@content)
  "    <\#{name} id=\"\#{html_id}\">\n      \#{content}\n      <a href=\"#\#{html_id}\">#</a>\n    </\#{name}>\n  END_HTML\nend\n"

#html_idObject



71
72
73
74
# File 'lib/elisp.rb', line 71

def html_id
  content = CGI.escape(@content)
  "#{@level}-#{content}"
end