<?phpfunction lisa ($f)
    {
    foreach ($f as $line)
        {
        if (substr ($line, 0, 2) == "//") continue;
        if ($line != "\n" && !$in)
            {
            if (!preg_match ("/([^:]*):\s(.*)/", $line, $a))
                {
                break;
                }
            $in    = $a[1];
            $id    = $a[1];
            $title    = $a[2];
            print "\n<div id='$id'>\n";
            print "\t<h1>$title</h1>\n";
            }
        elseif ($in)
            {
            if (preg_match ("/:$in/", $line))
                {
                $in = null;
                    if ($list)
                    {
                    close_list ($list);
                    $list = null;
                    }
                print "\n</div>\n";
                }
            elseif ($line[0] == "+")
                {
                print (substr ($line, 1));
                }
            else
                {
                if (preg_match ("/^\s*\*(.*)/", $line, $a))
                    {
                    if (!$list)
                        {
                        print "<ul>\n";
                        $list = "u";
                        }
                    $content = preg_replace ("/(\s*)\*(.*)/", "$1<li>$2</li>\n", trim ($line));
                    }
                elseif (preg_match ("/^\s*\#(.*)/", $line, $a))
                    {
                    if (!$list)
                        {
                        print "<ol>\n";
                        $list = "o";
                        }
                    $content = preg_replace ("/(\s*)\#(.*)/", "$1<li>$2</li>\n", trim ($line));
                    }
                elseif (preg_match ("/^dl:/", $line, $a))
                    {
                    $content = preg_replace ("/dl:/", "<dl>", trim ($line));
                    }
                elseif (preg_match ("/^:dl/", $line, $a))
                    {
                    $content = preg_replace ("/:dl/", "</dl>", trim ($line));
                    }
                elseif (preg_match ("/^\s*\>(.*)/", $line, $a))
                    {
                    $content = preg_replace ("/(\s*)\>(.*)/", "$1<dt>$2</dt>\n", trim ($line));
                    }
                elseif (preg_match ("/^\s*\=(.*)/", $line, $a))
                    {
                    $content = preg_replace ("/(\s*)\=(.*)/", "$1<dd>$2</dd>\n", trim ($line));
                    }
                else
                    {
                    if ($list)
                        {
                        close_list ($list);
                        $list = null;
                        }
                    $content = "<p>".trim ($line)."</p>";
                    }
                $content = preg_replace ("/\(([^\(\)]*)@(.*)\)/U", "<a href='$2'>$1</a>", trim ($content));
                $content = preg_replace ("/\s([\!\?\:\;])/", "&nbsp;$1", $content);

                $content = str_replace ("--", "&mdash;", $content);
                print "\t".trim ($content)."\n";
                }
            }
        }
    }

function close_list ($type)
    {
    switch ($type)
        {
        case "u":
            print "</ul>\n";
            break;
        case "o":
            print "</ol>\n";
            break;
        }
    }
?>