Skip to content

Instantly share code, notes, and snippets.

@lestrrat
Created March 30, 2010 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lestrrat/348720 to your computer and use it in GitHub Desktop.
Save lestrrat/348720 to your computer and use it in GitHub Desktop.
use strict;
use CGI;
use Cwd;
use Text::MultiMarkdown 'markdown';
my $q = CGI->new();
my $file = File::Spec->catfile(cwd(), $q->path_info());
open my $fh, '<', $file or die "Failed to open $file: $!";
my $content = do { local $/; <$fh> };
print $q->header(
-content_type => 'text/html; charset=utf-8',
),
wrap_html( markdown($content) );
;
sub wrap_html {
my ($markdown) = @_;
my $output = <<EOM;
<html>
<head>
<style type="text/css">
<!--
body {
font-family: Halvetica, sans-serif;
padding-left: 2em;
}
pre { padding-left: 2em }
-->
</style>
</head>
<body>
EOM
$output .= $markdown;
$output .= <<EOM;
</body>
</html>
EOM
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment