class Asciidoctor::Parser

def self.initialize_section reader, parent, attributes = {}

Returns the section [Block]

attributes - a Hash of attributes to assign to this section (default: {})
parent - the parent Section or Document of this Section
reader - the source reader

current position of the reader.
The information for this section is retrieved by parsing the lines at the

Internal: Initialize a new Section object and assign any attributes provided
def self.initialize_section reader, parent, attributes = {}
  document = parent.document
  book = (doctype = document.doctype) == 'book'
  source_location = reader.cursor if document.sourcemap
  sect_style = attributes[1]
  sect_id, sect_reftext, sect_title, sect_level, sect_atx = parse_section_title reader, document, attributes['id']
  if sect_reftext
    attributes['reftext'] = sect_reftext
  else
    sect_reftext = attributes['reftext']
  end
  if sect_style
    if book && sect_style == 'abstract'
      sect_name, sect_level = 'chapter', 1
    elsif (sect_style.start_with? 'sect') && (SectionLevelStyleRx.match? sect_style)
      sect_name = 'section'
    else
      sect_name, sect_special = sect_style, true
      sect_level = 1 if sect_level == 0
      sect_numbered = sect_name == 'appendix'
    end
  elsif book
    sect_name = sect_level == 0 ? 'part' : (sect_level > 1 ? 'section' : 'chapter')
  elsif doctype == 'manpage' && (sect_title.casecmp 'synopsis') == 0
    sect_name, sect_special = 'synopsis', true
  else
    sect_name = 'section'
  end
  section = Section.new parent, sect_level
  section.id, section.title, section.sectname, section.source_location = sect_id, sect_title, sect_name, source_location
  if sect_special
    section.special = true
    if sect_numbered
      section.numbered = true
    elsif document.attributes['sectnums'] == 'all'
      section.numbered = book && sect_level == 1 ? :chapter : true
    end
  elsif document.attributes['sectnums'] && sect_level > 0
    # NOTE a special section here is guaranteed to be nested in another section
    section.numbered = section.special ? parent.numbered && true : true
  elsif book && sect_level == 0 && document.attributes['partnums']
    section.numbered = true
  end
  # generate an ID if one was not embedded or specified as anchor above section title
  if (id = section.id || (section.id = (document.attributes.key? 'sectids') ? (generated_id = Section.generate_id section.title, document) : nil))
    # convert title to resolve attributes while in scope
    section.title if sect_title.include? ATTR_REF_HEAD unless generated_id
    unless document.register :refs, [id, section]
      logger.warn message_with_context %(id assigned to section already in use: #{id}), source_location: (reader.cursor_at_line reader.lineno - (sect_atx ? 1 : 2))
    end
  end
  section.update_attributes(attributes)
  reader.skip_blank_lines
  section
end