]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - fixup-docbook.rb
Translated using Weblate (Norwegian Bokmål)
[text-madewithcc.git] / fixup-docbook.rb
index 329d59935e27d4fa403682f0578c2d2519e1590f..7c527136b790b8a49769a3042e90f812e71efbed 100755 (executable)
@@ -53,8 +53,8 @@ partreplace(xml, 'colophon', 'colophon')
 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]
@@ -256,6 +256,15 @@ XML
 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')