" . $text . "\n";
}
// FIXME: this is a nonsense really. Might be okay if it
// used dynamic HTML but it's too much of a faff at the moment.
// Also, we should use the tree structure properly and keep a stack!
function outline_markup($filename,$thispage,$expanded) {
if ($title=="") { $title=$filename; };
$outline = false;
$file = file($filename);
$i = 0;
$level=0;
$headingno=0;
/* Now parse file, watching for outline headers */
for (;$i < count($file);$i++) {
$line = $file[$i];
// HTML escapes
$line = htmlentities($line);
// Anchors for URLs
$line = ereg_replace("((http://|mailto:)[-a-zA-Z0-9\.~/_@]+)","\\1",$line);
// Assume a heading
$multipar=false;
if (ereg("-\*- (mode:)?outline -\*-",$line)) {
// Found line with outline mode header, set flag
// and print message
$outline = true;
print "";
print "This is a flattened outline file: click on a title to hide/reveal the leaf underneath it.";
print "
Click ";
print "here to show whole body, or ";
print "here to hide whole body.";
print "
\n";
} elseif ($outline) {
if (ereg("^ *\n",$line)) {
// if (!newpara) { print "\n"; };
$newpara = true;
} elseif (ereg("^([\*]+) (.*)\n",$line,$heading)) {
$newlevel = strlen($heading[1])+1;
// if ($newlevel < $level) {
// Up a level
// $p = strpos($path,"-");
// $path = substr($path,0,$p-1);
if ($newpara &&
$level<=$newlevel &&
isexpanded($headingno,$expanded)) { print "
\n"; }
$headingno++;
$level=$newlevel;
$text="$heading[2]";
link_toggle($headingno,$text,$thispage,$filename,$expanded);
} elseif (isexpanded($headingno,$expanded)) {
if ($newpara && $level==0) { print "
\n"; }
print $line;
$newpara=false;
$level=0;
}
} else {
print $line;
}
}
}
//
// For browsing source. Unfinished.
//
function elisp_markup($filename,$thispage,$title="") {
if ($title=="") { $title=$filename; };
$file = file($filename);
$i = 0;
$level=0;
$headingno=0;
/* Now parse file, watching for outline headers */
for (;$i < count($file);$i++) {
$line = $file[$i];
// HTML escapes
$line = htmlentities($line);
// Anchors for URLs
$line = ereg_replace("((http://|mailto:)[-a-zA-Z0-9\.~/_@]+)","\\1",$line);
// Font-lock equivalents...
// 1. comments. Strings roughly done: ignore if quote appears after ;
// seems buggy.
// $line = ereg_replace("^([^;]*)(\;+[^\"]+)$",
// "\\1
\\2
",
// $line);
// 2. keywords
// FIXME: this inserts CR's.
// $line = ereg_replace("^\(def(macro|un|var|custom|const|group)",
// "(def\\1
",
// $line);
// FIXME: add hrefs for keywords, looking up in TAGS file.
// FIXME: add line numbers
// FIXME: parse strings
print $line;
}
}