3 ##########################################################################
5 # Filter to parse the ChangeLog and translate the changes for
6 # the most recent version into something that looks like markup
7 # for the documentation but still needs fine-tuning.
9 # Copyright (c) 2008, 2010 Fabian Keil <fk@fabiankeil.de>
11 # Permission to use, copy, modify, and distribute this software for any
12 # purpose with or without fee is hereby granted, provided that the above
13 # copyright notice and this permission notice appear in all copies.
15 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 ##########################################################################
30 my $section_reached = 0;
35 last if $section_reached;
39 next unless $section_reached;
43 my $indentation = length($1);
44 if ($i > 1 and $entries[$i]{indentation} > $indentation) {
45 $entries[$i]{last_list_item} = 1;
48 $entries[$i]{description} = '';
49 $entries[$i]{indentation} = $indentation;
52 $entries[$i]{list_header} = 1;
57 $entries[$i]{description} .= $_;
59 if ($entries[$i]{indentation} != 0) {
60 $entries[$i]{last_list_item} = 1;
62 print "Parsed " . @entries . " entries.\n";
65 sub create_listitem_markup($) {
67 my $description = $entry->{description};
69 my $default_lws = ' ';
70 my $lws = $default_lws x ($entry->{indentation} ? 2 : 1);
74 $description =~ s@\n@\n ${lws}@g;
76 $markup .= $lws . "<listitem>\n" .
79 $markup .= $lws . " " . $description . "\n";
81 if (defined $entry->{list_header}) {
82 $markup .= $lws . " <itemizedlist>\n";
85 if (defined $entry->{last_list_item}) {
86 $markup .= $lws . " </para>\n";
87 $markup .= $lws . " </listitem>\n";
88 $markup .= $lws . "</itemizedlist>\n";
91 $markup .= $lws . " </para>\n" .
92 $lws . "</listitem>\n";
98 sub wrap_in_para_itemlist_markup($) {
100 my $markup = "<para>\n" .
101 " <itemizedlist>\n" .
103 " </itemizedlist>\n" .
108 sub generate_markup() {
111 foreach my $entry (@entries) {
112 $markup .= create_listitem_markup(\%{$entry});
115 print wrap_in_para_itemlist_markup($markup);