]> pere.pagekite.me Git - text-madewithcc.git/commitdiff
Add code to remove empty notes/web links sections.
authorPetter Reinholdtsen <pere@hungry.com>
Fri, 9 Feb 2018 10:12:11 +0000 (11:12 +0100)
committerPetter Reinholdtsen <pere@hungry.com>
Thu, 22 Feb 2018 18:12:09 +0000 (18:12 +0000)
Makefile
fixup-docbook.rb

index 1037f9d34568ed4cfbda6ec7c3496f9560180b18..6cd997d87e1555725a6a5e6f24838bf3e7a90a4a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -102,9 +102,7 @@ DBLATEX_OPTS = -T simple -t tex -b xetex -p extra/pdf.xsl
 %.tex: %.xml
        dblatex $(DBLATEX_OPTS) $^
        perl -p -i -e 's/ / /g; \
-               s/\\chapter\{(Colophon|Dedication)\}/\\chapter*{}/; \
-               s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
-               s/(Web links?|Vínculos Web)/\\section*{$$1}/;' $@
+               s/\\chapter\{(Colophon|Dedication)\}/\\chapter*{}/;' $@
 
 XMLLINTOPTS = --nonet --noout  --xinclude --postvalid
 lint: $(SOURCE).xml
index 05f5a53214e0b0bd7515ec6c0b23287ba7191f17..5de33e71ca8d4452c32430f433d0da48f64641a0 100755 (executable)
@@ -66,6 +66,24 @@ if s
   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 = ""