]> pere.pagekite.me Git - text-madewithcc.git/commitdiff
Transform source docbook to use <xref> tags as figure references.
authorPetter Reinholdtsen <pere@hungry.com>
Mon, 9 Dec 2019 15:52:01 +0000 (16:52 +0100)
committerPetter Reinholdtsen <pere@hungry.com>
Mon, 9 Dec 2019 15:54:54 +0000 (16:54 +0100)
This invalidates the translations, but ensure docbook control the look
of references.

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')