[Commits] [svn:einsteintoolkit] www/documentation/licenses/ (Rev. 602)

knarf at cct.lsu.edu knarf at cct.lsu.edu
Wed Aug 17 11:14:37 CDT 2011


User: knarf
Date: 2011/08/17 11:14 AM

Modified:
 /documentation/licenses/
  parse_citations.pl

Log:
 collapse table

File Changes:

Directory: /documentation/licenses/
===================================

File [modified]: parse_citations.pl
Delta lines: +27 -2
===================================================================
--- documentation/licenses/parse_citations.pl	2011-08-17 15:39:37 UTC (rev 601)
+++ documentation/licenses/parse_citations.pl	2011-08-17 16:14:37 UTC (rev 602)
@@ -32,12 +32,37 @@
   }
   # sort
   @arr_of_arr = sort {my (@aa, at bb); @aa = keys(%$a); @bb = keys(%$b); $aa[0] cmp $bb[0]} @arr_of_arr;
+  # collapse
+  my @arr2_of_arr = ();
+  my $last_key = "";
+  foreach my $elem (@arr_of_arr) {
+    my %mapp = %$elem;
+    my $key  = (keys(%mapp))[0];
+    if ($last_key ne $key) {
+      my @refs  = ($mapp{$key});
+      my %nelem = ($key => \@refs);
+      push(@arr2_of_arr, \%nelem);
+    } else {
+      push(@{$arr2_of_arr[scalar(@arr2_of_arr)-1]{$key}}, $mapp{$key});
+    }
+    $last_key = $key;
+  }
+
   # output
   print "<table>\n";
-  foreach my $elem (@arr_of_arr) {
+  foreach my $elem (@arr2_of_arr) {
     my %mapp = %$elem;
     my $key  = (keys(%mapp))[0];
-    print "<tr><th align='left'>".$key."</th><td>".$mapp{$key}."</td></tr>\n";
+    my $count = scalar(@{$mapp{$key}});
+    my $first = 1;
+    for my $ref (@{$mapp{$key}}) {
+      if ($first) {
+        print "<tr><th align='left' rowspan='$count'>".$key."</th><td>$ref</td></tr>\n";
+      } else {
+        print "<tr><td>$ref</td></tr>\n";
+      }
+      $first = 0;
+    }
   }
   print "</table>\n";
 }



More information about the Commits mailing list