From: Nigel Metheringham Date: Sun, 4 Jul 2010 13:25:42 +0000 (+0100) Subject: Add id tags to chapters/sections missing them X-Git-Tag: exim-4_89_1~118 X-Git-Url: https://git.exim.org/exim-website.git/commitdiff_plain/823d5e910b06dab984445f59399fa0ad39eba3ea?ds=inline Add id tags to chapters/sections missing them --- diff --git a/script/gen.pl b/script/gen.pl index 4c545f5..1fbb026 100755 --- a/script/gen.pl +++ b/script/gen.pl @@ -163,7 +163,11 @@ sub xref_fixup { foreach my $chapter ( $xml->findnodes('/book/chapter') ) { ++$chapter_counter; - my $chapter_id = $chapter->getAttribute('id'); + my $chapter_id = $chapter->getAttribute('id'); + unless ($chapter_id) { # synthesise missing id + $chapter_id = sprintf( 'chapter_noid_%04d', $chapter_counter ); + $chapter->setAttribute( 'id', $chapter_id ); + } my $chapter_title = $chapter->findvalue('title'); $index{$chapter_id} = { chapter_id => $chapter_counter, chapter_title => $chapter_title }; @@ -173,7 +177,11 @@ sub xref_fixup { foreach my $section ( $chapter->findnodes('section') ) { ++$section_counter; - my $section_id = $section->getAttribute('id'); + my $section_id = $section->getAttribute('id'); + unless ($section_id) { # synthesise missing id + $section_id = sprintf( 'section_noid_%04d_%04d', $chapter_counter, $section_counter ); + $section->setAttribute( 'id', $section_id ); + } my $section_title = $section->findvalue('title'); $index{$section_id} =