partreplace(xml, 'dedication', 'dedication')
partreplace(xml, 'foreword', 'preface')
partreplace(xml, 'introduction', 'preface')
-partreplace(xml, 'bibliography', 'chapter')
-partreplace(xml, 'acknowledgments', 'chapter')
+partreplace(xml, 'bibliography', 'appendix')
+partreplace(xml, 'acknowledgments', 'appendix')
log 0, 'place part introduction into <partintro>'
s = xml.xpath("//part/title[text()='The Case Studies']")[0]
end
end
+log 0, 'replace "Fig. \#." with docbook figure xref'
+xml.css("para").each do |para|
+ xml_text = para.to_xml(:skip_instruct => true).to_s
+ xml_text.gsub!(/Fig\.\s+(\d)\.?/,
+ 'Fig. <xref xrefstyle="template:%n" linkend="fig-\\1"/>')
+ para.after(xml_text)
+ para.remove
+end
+
log 0, 'Writing processed file'
# Unable to figure out API way to replace DOCTYPE
data = xml.to_xml().gsub!(/DOCTYPE article/, 'DOCTYPE book')