Index: trunk/dvodist/www-util/ipp.php
===================================================================
--- trunk/dvodist/www-util/ipp.php	(revision 33986)
+++ trunk/dvodist/www-util/ipp.php	(revision 34748)
@@ -1,6 +1,5 @@
 <?php
 
-global $realroot;
-$realroot = "/dvodist";
+global $rootdir;
 
 function head ($title) {
@@ -34,4 +33,5 @@
 }
 
+// generate the menu based on the text file
 function menulines ($source, $root, $append, $project) {
 
@@ -43,4 +43,5 @@
     if (count($line) < 2) continue;
 
+    // allow load of other menu files
     if (count($line) == 2) {
       $value = trim($line[0]);
@@ -51,4 +52,6 @@
       continue;
     }
+
+    // blithly skip lines with invalid entries
     if (count($line) != 5) continue;
 
@@ -73,9 +76,9 @@
     } 
 
-    global $realroot;
+    global $rootdir;
 
     // hi-lite the current page (use select-style, not style)
     $thisname = $_SERVER[SCRIPT_NAME]; 
-    $page = $realroot . $base;
+    $page = $rootdir . $base;
     if ($page == $thisname) {
       $style = trim($line[1]);
@@ -117,4 +120,6 @@
 
 function dirlist ($source) {
+  if (!file_exists($source)) return;
+
   $file = fopen ($source, "r");
   echo "<table class=\"dirlist\">\n";
@@ -135,10 +140,26 @@
     // }
 
-    if (count($line) != 4) continue;
-
-    $name  = trim($line[0]);
-    $type  = trim($line[1]);
-    $style = trim($line[2]);
-    $info  = trim($line[3]);
+    if ((count($line) != 4) && (count($line) != 5)) continue;
+
+    // support both the old and new style tables:
+    // old: name | type | style | info
+    // new: name | link | type | style | info
+
+    if (count($line) == 4) {
+      echo "count = 4<br>\n";
+      $name  = trim($line[0]);
+      $type  = trim($line[1]);
+      $style = trim($line[2]);
+      $info  = trim($line[3]);
+      $link  = $name;
+    }
+    if (count($line) == 5) {
+      echo "count = 5<br>\n";
+      $name  = trim($line[0]);
+      $link  = trim($line[1]);
+      $type  = trim($line[2]);
+      $style = trim($line[3]);
+      $info  = trim($line[4]);
+    }
 
     switch ($type) { 
@@ -158,5 +179,54 @@
 }
 
+function parse_dirlist ($input) {
+  echo "<table class=\"dirlist\">\n";
+
+  $inlist = explode ("\n", $input);
+  $Ninlist = count($inlist);
+  for ($i = 0; $i < $Ninlist; $i++) {
+    $inline = trim ($inlist[$i], "@ \t");
+    $line = explode (":", $inline);
+    if (ereg ('^[:blank:]*#', $line[0])) continue;
+    if (count($line) < 2) continue;
+
+    if ((count($line) != 4) && (count($line) != 5)) continue;
+
+    // support both the old and new style tables:
+    // old: name | type | style | info
+    // new: name | link | type | style | info
+
+    if (count($line) == 4) {
+      $name  = trim($line[0]);
+      $type  = trim($line[1]);
+      $style = trim($line[2]);
+      $info  = trim($line[3]);
+      $link  = $name;
+    }
+    if (count($line) == 5) {
+      $name  = trim($line[0]);
+      $link  = trim($line[1]);
+      $type  = trim($line[2]);
+      $style = trim($line[3]);
+      $info  = trim($line[4]);
+    }
+
+    switch ($type) { 
+    case 'plain':
+      echo "<tr class=\"$style\"><td>$name</td><td>$info</td></tr>\n";  
+      break;
+    case 'dir':
+      echo "<tr class=\"$style\"><td><a class=\"$style\" href=\"$name\">$name</a></td><td>$info</td></tr>\n";
+      break;
+    default:
+      echo "<tr class=\"$style\"><td><a class=\"$style\" href=\"$name\">$name</a></td><td>$info</td></tr>\n";
+      break;
+    } 
+  }
+  echo "</table>\n";
+}
+
 function verbatim ($source) {
+  if (!file_exists($source)) return;
+
   $file = fopen ($source, "r");
 
@@ -165,4 +235,5 @@
   // loop over the lines in the file and generate lines in the menu
   while ($line = fgets ($file, 1024)) {
+    echo "line: $line<br>\n";
     if (strlen($line) < 2) {
       if (!$addbreak) {
@@ -176,4 +247,50 @@
     $addbreak = 0;
   } 
+  fclose ($file);
+}
+
+// lines which start with @ are processed by 'dirlist', all others are processed by Markdown
+function do_markdown ($source) {
+  if (!file_exists($source)) return;
+
+  $file = fopen ($source, "r");
+
+  // loop over the lines in the file and generate lines in the menu
+  $to_markdwn = "";
+  $to_dirlist = "";
+  while ($line = fgets ($file, 1024)) {
+    // echo "line: $line";
+    if (!strncmp($line, "@", 1)) {
+      if ($to_markdwn) {
+	// echo "<b> start markdown</b><br>\n";
+	$my_html = Markdown($to_markdwn);
+	echo "$my_html";
+	$to_markdwn = "";
+      }
+      $to_dirlist .= $line;
+    } else {
+      if ($to_dirlist) {
+	// echo "<b> start dirlist</b><br>\n";
+	parse_dirlist($to_dirlist);
+	$to_dirlist = "";
+      }
+      $to_markdwn .= $line;
+    }
+  }
+  // echo "end of lines<br>\n";
+  // echo "to_markdwn: $to_markdwn\n";
+  // echo "<br>\n";
+  // echo "to_dirlist: $to_dirlist\n";
+  // echo "<br>\n";
+
+  if ($to_markdwn) {
+    $my_html = Markdown($to_markdwn);
+    echo "$my_html";
+    $to_markdwn = "";
+  }
+  if ($to_dirlist) {
+    parse_dirlist($to_dirlist);
+    $to_dirlist = "";
+  }
   fclose ($file);
 }
