]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - fixup-docbook.rb
Add code to remove empty notes/web links sections.
[text-madewithcc.git] / fixup-docbook.rb
index 05f5a53214e0b0bd7515ec6c0b23287ba7191f17..5de33e71ca8d4452c32430f433d0da48f64641a0 100755 (executable)
@@ -66,6 +66,24 @@ if s
   end
 end
 
   end
 end
 
+
+log 0, 'remove empty notes/web links sections'
+[
+  'Notes',
+  'Web links',
+  'Web link',
+].each do |title|
+  xml.xpath("//title[text()='%s']" % title).each do |node|
+    p = node.parent
+    node.remove
+    if p.content =~ /^\s*$/
+      p.remove
+    else
+      raise RuntimeError, 'Non-empty «%s» found' % title
+    end
+  end
+end
+
 log 0, 'remove title from dedication'
 xml.css('dedication title')[0].content = ""
 
 log 0, 'remove title from dedication'
 xml.css('dedication title')[0].content = ""