Store entries in an array of hashes so we can later add the indentation level.
[privoxy.git] / utils / changelog2doc.pl
index adf2f92..bfa23b0 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
-# $Id:$
-# $Source:$
+# $Id: changelog2doc.pl,v 1.3 2010/10/31 13:25:47 fabiankeil Exp $
+# $Source: /cvsroot/ijbswa/current/utils/changelog2doc.pl,v $
 
 # Filter to parse the ChangeLog and translate the changes for
 # the most recent version into something that looks like markup
@@ -27,13 +27,27 @@ sub read_entries() {
 
         if (/^-/) {
             $i++; 
-            $entries[$i] = '';
+            $entries[$i]{description} = '';
         }
         s@^-?\s*@@;
 
-        $entries[$i] .= $_;
+        $entries[$i]{description} .= $_;
     }
-    print "Parsed $i entries.\n";
+    print "Parsed " . @entries . " entries.\n";
+}
+
+sub create_listitem_markup($) {
+    my $entry = shift;
+    my $description = $entry->{description};
+
+    chomp $description;
+
+    $description =~ s@\n@\n    @g;
+    return "  <listitem>\n" .
+           "   <para>\n" .
+           "    " . $description . "\n" .
+           "   </para>\n" .
+           "  </listitem>\n";
 }
 
 sub generate_markup() {
@@ -43,15 +57,9 @@ sub generate_markup() {
                " <itemizedlist>\n";
 
     foreach my $entry (@entries) {
-        chomp $entry;
-        $entry =~ s@\n@\n    @g;
-        $markup .= "  <listitem>\n" .
-                   "   <para>\n" .
-                   "    " . $entry . "\n" .
-                   "   </para>\n" .
-                   "  </listitem>\n"
-                   ;
+        $markup .= create_listitem_markup(\%{$entry});
     }
+
     $markup .= " </itemizedlist>\n" .
                "</para>\n";