def self.initialize_section(reader, parent, attributes = {})
section = Section.new parent
section.id, section.title, section.level, _ = parse_section_title(reader, section.document)
if attributes[1]
section.sectname, _ = parse_style_attribute(attributes)
section.special = true
document = parent.document
if section.sectname == 'abstract' && document.doctype == 'book'
section.sectname = "sect1"
section.special = false
section.level = 1
elsif section.sectname == 'appendix' &&
!attributes.has_key?('caption') &&
!document.attributes.has_key?('caption')
number = document.counter('appendix-number', 'A')
section.caption = "#{document.attributes['appendix-caption']} #{number}: "
Document::AttributeEntry.new('appendix-number', number).save_to(attributes)
end
else
section.sectname = "sect#{section.level}"
end
if section.id.nil? && (id = attributes['id'])
section.id = id
else
section.id ||= section.generate_id
end
if section.id
section.document.register(:ids, [section.id, section.title])
end
section.update_attributes(attributes)
reader.skip_blank_lines
section
end