Create a gist now

Instantly share code, notes, and snippets.

Embed
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