Class: Elisp::Heading
- Inherits:
-
Object
- Object
- Elisp::Heading
- Defined in:
- lib/elisp/heading.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(content, level: 2) ⇒ Heading
constructor
A new instance of Heading.
- #pandoc_json_object ⇒ Object
Constructor Details
#initialize(content, level: 2) ⇒ Heading
Returns a new instance of Heading.
21 22 23 24 |
# File 'lib/elisp/heading.rb', line 21 def initialize(content, level: 2) @content = content @level = level end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
19 20 21 |
# File 'lib/elisp/heading.rb', line 19 def content @content end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
19 20 21 |
# File 'lib/elisp/heading.rb', line 19 def level @level end |
Instance Method Details
#html ⇒ Object
26 27 28 29 30 |
# File 'lib/elisp/heading.rb', line 26 def html name = "h#{@level}" content = CGI.escape_html(@content) "<#{name}>#{content}</#{name}>" end |
#pandoc_json_object ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/elisp/heading.rb', line 32 def pandoc_json_object { "t": "Header", "c": [ @level, [@content, [], []], [ { "t": "Str", "c": @content, }, ], ] } end |