From 07ed7ba4cce9ee51d8ff83cd82a381e0611f45b6 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 31 Oct 2010 13:28:19 +0000 Subject: [PATCH] Add support for the new ChangeLog format. While the generated markup looks somewhat reasonable, it hasn't actually been validated yet. --- utils/changelog2doc.pl | 48 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/utils/changelog2doc.pl b/utils/changelog2doc.pl index 6ed30c0d..e61be0c5 100755 --- a/utils/changelog2doc.pl +++ b/utils/changelog2doc.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: changelog2doc.pl,v 1.4 2010/10/31 13:26:07 fabiankeil Exp $ +# $Id: changelog2doc.pl,v 1.5 2010/10/31 13:27:03 fabiankeil Exp $ # $Source: /cvsroot/ijbswa/current/utils/changelog2doc.pl,v $ # Filter to parse the ChangeLog and translate the changes for @@ -25,29 +25,59 @@ sub read_entries() { next unless $section_reached; next if /^\s*$/; - if (/^-/) { + if (/^(\s*)-/) { + my $indentation = length($1); + if ($i > 1 and $entries[$i]{indentation} > $indentation) { + $entries[$i]{last_list_item} = 1; + } $i++; $entries[$i]{description} = ''; + $entries[$i]{indentation} = $indentation; } - s@^-?\s*@@; + if (/:\s*$/) { + $entries[$i]{list_header} = 1; + } + + s@^\s*-?\s*@@; $entries[$i]{description} .= $_; } + if ($entries[$i]{indentation} != 0) { + $entries[$i]{last_list_item} = 1; + } print "Parsed " . @entries . " entries.\n"; } sub create_listitem_markup($) { my $entry = shift; my $description = $entry->{description}; + my $markup = ''; + my $default_lws = ' '; + my $lws = $default_lws x ($entry->{indentation} ? 2 : 1); chomp $description; - $description =~ s@\n@\n @g; - return " \n" . - " \n" . - " " . $description . "\n" . - " \n" . - " \n"; + $description =~ s@\n@\n ${lws}@g; + + $markup .= $lws . "\n" . + $lws . " \n"; + + $markup .= $lws . " " . $description . "\n"; + + if (defined $entry->{list_header}) { + $markup .= $lws . " \n"; + + } else { + if (defined $entry->{last_list_item}) { + $markup .= $lws . " \n"; + $markup .= $lws . "\n"; + $lws = $default_lws; + } + $markup .= $lws . " \n" . + $lws . "\n"; + } + + return $markup; } sub wrap_in_para_itemlist_markup($) { -- 2.39.2