Class: AsciidoctorVaped::Parser::Blocks::Heading

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/asciidoctor_vaped/parser/blocks/heading.rb

Constant Summary collapse

PATTERN =
/\A(=+)\s+(.+)\z/

Instance Method Summary collapse

Methods inherited from BaseNode

#handle, #initialize, #match?

Constructor Details

This class inherits a constructor from AsciidoctorVaped::Parser::Blocks::BaseNode

Instance Method Details

#parse(context) ⇒ Object



11
12
13
14
15
# File 'lib/asciidoctor_vaped/parser/blocks/heading.rb', line 11

def parse(context)
  markers, title = context.reader.read.match(PATTERN).captures
  level = [markers.length - 1, 1].max
  context.open_section AST::Element.new(:section, attributes: { level: }, children: Inline.parse(title))
end