turn pre-chapter elements of a CRI(COM) into a preface (#6627)

This commit is contained in:
Frédéric Péters 2015-03-09 08:32:06 +01:00
parent 6cb4bd58cd
commit f704bc3860
1 changed files with 9 additions and 0 deletions

View File

@ -968,6 +968,15 @@ def convert_to_legi_xml(content, metadata = None):
if speaker_annotation is not None:
if speech: # there was a speech, pop it
current_top.pop()
if current_top[-1].tag == 'book':
if current_top[-1].getchildren()[-1].tag == 'nosection':
# This is a CRI(COM), and there's a speaker up in the
# document introducing the seance, before any structure.
# Fiddle around the document to change from <nosection>
# to <preface>
current_top.append(current_top[-1].getchildren()[-1])
current_top[-1].tag = 'preface'
speech = ET.SubElement(current_top[-1], 'speech')
current_top.append(speech)
ref = ET.SubElement(speech, 'ref')