Permalink
Browse files

markdown_preview: make it really kickass

  • Loading branch information...
1 parent 6188193 commit 2d6788fbe0924b0bb2725a04bc094b14e9275798 @trapd00r committed Jan 7, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 markdown_preview
View
@@ -1,6 +1,11 @@
#!/usr/bin/perl
use strict;
-use warnings FATAL => 'all';
use Text::Markdown qw(markdown);
+use File::Temp qw(tempfile);
-print markdown(do { local $/; <> });
+my($fh, $file) = tempfile('markdown_previewXXXX', SUFFIX => '.html');
+print $fh markdown(do { local $/; <> });
+close $fh;
+
+system( ($ENV{DISPLAY}) ? 'x-www-browser' : $ENV{BROWSER}, $file);
+unlink $file;

0 comments on commit 2d6788f

Please sign in to comment.