Class: Elisp::Heading

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



19
20
21
# File 'lib/elisp/heading.rb', line 19

def content
  @content
end

#levelObject (readonly)

Returns the value of attribute level.



19
20
21
# File 'lib/elisp/heading.rb', line 19

def level
  @level
end

Instance Method Details

#htmlObject



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_objectObject



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