#!/usr/bin/perl -w # # $Id: markdown,v 1.4 2007/04/24 17:56:47 vogelke Exp $ # #; close($ifh); } else { $title = 'Unknown'; $date = scalar(localtime(time())); open($ifh, "<-") || die "cannot open stdin: $!\n"; undef $/; $contents = <$ifh>; } # get version id, if any. $_ = $contents; $rev = 'unknown'; if (//) { $rev = $1; } # handle anything else that might be missing from markdown. # format results. if (open($ofh, "| $prog")) { header(); print {$ofh} $contents; close($ofh); footer(); } else { warn "unable to pipe to $prog: $!\n"; } exit(0); # ----------------------------------------------------------------------- # Use this when fonts are fixed: ## font-family: Verdana, Geneva, Arial, Sans-serif; sub header { my $bc = breadcrumbs(); my $css = $ENV{'MKDSTYLE'} || '/style/basic.css'; print <<"Header"; $title
Header return 1; } # ----------------------------------------------------------------------- # Footer sub footer { print <<"Footer";

Footer return 1; } # ----------------------------------------------------------------------- # Breadcrumb line. sub breadcrumbs { use Cwd 'abs_path'; # What divider should I use between path components? my $divider = ' > '; my ($p, @p); my $path = shift || Cwd->cwd(); # Replace directory with appropriate link. # FIXME: should come from an external file. my %docroot = ( '/doc/html/faq' => '/faq', '/doc/html/htdocs' => '/', ); foreach (keys %docroot) { $path =~ s!^$_/!!; } # Set home link, then walk the path. push @p, 'Home'; foreach (split /\//, $path) { $p .= "/$_"; push @p, $p ne "/$path" ? qq{$_} : qq{$_}; } return join $divider, @p; }