def self.parse_manpage_header(reader, document)
if (m = ManpageTitleVolnumRx.match(document.attributes['doctitle']))
document.attributes['mantitle'] = document.sub_attributes(m[1].rstrip.downcase)
document.attributes['manvolnum'] = m[2].strip
else
warn %(asciidoctor: ERROR: #{reader.prev_line_info}: malformed manpage title)
document.attributes['mantitle'] = document.attributes['doctitle']
document.attributes['manvolnum'] = '1'
end
reader.skip_blank_lines
if is_next_line_section?(reader, {})
name_section = initialize_section(reader, document, {})
if name_section.level == 1
name_section_buffer = reader.read_lines_until(:break_on_blank_lines => true).join(' ').tr_s(' ', ' ')
if (m = ManpageNamePurposeRx.match(name_section_buffer))
document.attributes['manname'] = document.sub_attributes m[1]
document.attributes['manpurpose'] = m[2]
if document.backend == 'manpage'
document.attributes['docname'] = document.attributes['manname']
document.attributes['outfilesuffix'] = %(.#{document.attributes['manvolnum']})
end
else
warn %(asciidoctor: ERROR: #{reader.prev_line_info}: malformed name section body)
end
else
warn %(asciidoctor: ERROR: #{reader.prev_line_info}: name section title must be at level 1)
end
else
warn %(asciidoctor: ERROR: #{reader.prev_line_info}: name section expected)
end
end