From: Petter Reinholdtsen Date: Fri, 9 Feb 2018 10:12:11 +0000 (+0100) Subject: Add code to remove empty notes/web links sections. X-Git-Tag: es-printed~501 X-Git-Url: https://pere.pagekite.me/gitweb/text-madewithcc.git/commitdiff_plain/cad86ab2fddbd46996c61e27cd2563e81f3ba8c3 Add code to remove empty notes/web links sections. --- 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 = ""