From cad86ab2fddbd46996c61e27cd2563e81f3ba8c3 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Fri, 9 Feb 2018 11:12:11 +0100 Subject: [PATCH] Add code to remove empty notes/web links sections. --- Makefile | 4 +--- fixup-docbook.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1037f9d..6cd997d 100644 --- 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 diff --git a/fixup-docbook.rb b/fixup-docbook.rb index 05f5a53..5de33e7 100755 --- a/fixup-docbook.rb +++ b/fixup-docbook.rb @@ -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 = "" -- 2.47.2