]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - fixup-docbook.rb
Translated using Weblate (Norwegian Bokmål)
[text-madewithcc.git] / fixup-docbook.rb
index a0504965cb92f5b91a8e6059f2aebef8d2ddd662..7c527136b790b8a49769a3042e90f812e71efbed 100755 (executable)
@@ -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')