a2x: spine info should be modified to allow internal documents that are not...
Brought to you by:
sjrackham
modified the a2x script this way :
manifest = opf.getElementsByTagName('manifest')[0]
#new spine element (1 line)
spine = opf.getElementsByTagName('spine')[0]
for el in manifest.getElementsByTagName('item'):
f = el.getAttribute('href')
f = os.path.normpath(f)
manifest_files.append(f)
count = 0
for f in resource_files:
if f not in manifest_files:
count += 1
verbose('adding to manifest: %s' % f)
item = opf.createElement('item')
item.setAttribute('href', f.replace(os.path.sep, '/'))
item.setAttribute('id', 'a2x-%d' % count)
mimetype = mimetypes.guess_type(f)[0]
if mimetype is None:
die('unknown mimetype: %s' % f)
#new spine element
if 'image/' not in mimetype:
itemref = opf.createElement('itemref')
itemref.setAttribute('idref', 'a2x-%d' % count)
itemref.setAttribute('linear', 'no')
spine.appendChild(itemref)
# end new
item.setAttribute('media-type', mimetype)
manifest.appendChild(item)
if count > 0:
#verbose( 'opf %s' % opf.toxml() )
# NEW replaces: write_file(opf_file, opf.toxml())
write_file(opf_file, opf.toprettyxml(indent=" ", encoding=opf.encoding), mode="wb")
OOps :indenting is not correct in the example (dues to copy/paste problem) please indent the 'spine' modification into the enclosing for loop