Class: Protos::Markdown::Heading

Inherits:
Data
  • Object
show all
Defined in:
lib/protos/markdown.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node

Returns:

  • (Object)

    the current value of node



17
18
19
# File 'lib/protos/markdown.rb', line 17

def node
  @node
end

Instance Method Details

#header_levelObject



32
33
34
# File 'lib/protos/markdown.rb', line 32

def header_level
  node.header_level
end

#idObject



18
19
20
# File 'lib/protos/markdown.rb', line 18

def id
  text.downcase.gsub(/[^a-z0-9]+/, "-").chomp("-")
end

#textObject



22
23
24
25
26
27
28
29
30
# File 'lib/protos/markdown.rb', line 22

def text
  buffer = +""
  node.walk do |node|
    buffer << node.string_content
  rescue TypeError
    # Ignore non-text nodes
  end
  buffer
end