# File lib/asciidoctor/parser.rb, line 1568
  def self.initialize_section(reader, parent, attributes = {})
    document = parent.document
    source_location = reader.cursor if document.sourcemap
    sect_id, sect_reftext, sect_title, sect_level, _ = parse_section_title(reader, document)
    attributes['reftext'] = sect_reftext if sect_reftext
    section = Section.new parent, sect_level, document.attributes.has_key?('sectnums')
    section.source_location = source_location if source_location
    section.id = sect_id
    section.title = sect_title
    # parse style, id and role from first positional attribute
    if attributes[1]
      style, _ = parse_style_attribute attributes, reader
      # handle case where only id and/or role are given (e.g., #idname.rolename)
      if style
        section.sectname = style
        section.special = true
        # HACK needs to be refactored so it's driven by config
        if section.sectname == 'abstract' && document.doctype == 'book'
          section.sectname = 'sect1'
          section.special = false
          section.level = 1
        end
      else
        section.sectname = %(sect#{section.level})
      end
    elsif sect_title.downcase == 'synopsis' && document.doctype == 'manpage'
      section.special = true
      section.sectname = 'synopsis'
    else
      section.sectname = %(sect#{section.level})
    end

    if !section.id && (id = attributes['id'])
      section.id = id
    else
      # generate an id if one was not *embedded* in the heading line
      # or as an anchor above the section
      section.id ||= section.generate_id
    end

    if section.id
      # TODO sub reftext
      section.document.register(:ids, [section.id, (attributes['reftext'] || section.title)])
    end
    section.update_attributes(attributes)
    reader.skip_blank_lines

    section
  end