Created
October 11, 2010 05:40
-
-
Save mshroyer/620037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# mt-export-markdown.pl: Process Movable Type export files | |
# containing Markdown posts into pure HTML. | |
# | |
# Mark Shroyer | |
# Mon Oct 11 01:37:52 EDT 2010 | |
use warnings; | |
use strict; | |
use Text::Markdown qw(markdown); | |
while (<>) { | |
print $_; | |
if ( /^(?:EXTENDED )?BODY:$/ ) { | |
my $source = ''; | |
while (<>) { | |
last if ( /^-{5}$/ ); | |
$source .= $_; | |
} | |
if ( $source =~ /^</ ) { | |
# If body looks like it's already HTML, just echo it | |
print $source; | |
} | |
else { | |
# Otherwise run it through the Markdown formatter | |
print markdown($source); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment