Skip to content

Instantly share code, notes, and snippets.

@mshroyer
Created October 11, 2010 05:40
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 mshroyer/620037 to your computer and use it in GitHub Desktop.
Save mshroyer/620037 to your computer and use it in GitHub Desktop.
#!/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