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
if attributes[1]
style, _ = parse_style_attribute attributes, reader
if style
section.sectname = style
section.special = true
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
section.id ||= section.generate_id
end
if section.id
section.document.register(:ids, [section.id, (attributes['reftext'] || section.title)])
end
section.update_attributes(attributes)
reader.skip_blank_lines
section
end