Skip to content

Instantly share code, notes, and snippets.

@bcantoni
Created April 8, 2014 15:47
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 bcantoni/10145999 to your computer and use it in GitHub Desktop.
Save bcantoni/10145999 to your computer and use it in GitHub Desktop.
Mods needed for migrating my blog from MovableType 4.x to WordPress 3.8
# mt-export-markdown.pl: Process Movable Type export files
# containing Markdown and Textile posts into pure HTML.
#
# Brian Cantoni
# 2004-04-18
#
# Modified from Mark Shroyer's original script:
# http://markshroyer.com/2010/10/mt-markdown-to-wp/
#
# Usage:
# 1. Export all posts from Movable Type into text file (ex: mt.txt)
# 2. Process text file thru this script (ex: perl conver.pl <mt.txt >wp.txt)
# 3. Import processed file (wp.txt) into WordPress
use warnings;
use strict;
use Text::Markdown qw(markdown);
use Text::Textile qw(textile);
while (<>) {
print $_;
if ( /^(?:EXTENDED )?BODY:$/ ) {
my $source = '';
while (<>) {
last if ( /^-{5}$/ );
$source .= $_;
}
if ( $source =~ /\":http/ ) {
# If body looks like Textile
print textile ($source) . "\n";
}
else {
# Otherwise run it through the Markdown formatter
print markdown($source);
}
}
}
--- ImportExport.pm.bak 2014-04-01 12:45:00.873266322 -0400
+++ ImportExport.pm 2014-04-01 17:35:53.995130625 -0400
@@ -483,15 +483,14 @@
$tmpl->text(<<'TEXT');
AUTHOR: <$MTEntryAuthor strip_linefeeds="1"$>
TITLE: <$MTEntryTitle strip_linefeeds="1"$>
-BASENAME: <$MTEntryBasename$>
+BASENAME: <mt:IfNonEmpty tag="EntryKeywords"><$MTEntryKeywords$><mt:Else><$MTEntryTitle dirify="1"></mt:IfNonEmpty>
STATUS: <$MTEntryStatus strip_linefeeds="1"$>
ALLOW COMMENTS: <$MTEntryFlag flag="allow_comments"$>
CONVERT BREAKS: <$MTEntryFlag flag="convert_breaks"$>
ALLOW PINGS: <$MTEntryFlag flag="allow_pings"$><MTIfNonEmpty tag="MTEntryCategory">
PRIMARY CATEGORY: <$MTEntryCategory$></MTIfNonEmpty><MTEntryCategories>
CATEGORY: <$MTCategoryLabel$></MTEntryCategories>
-DATE: <$MTEntryDate format="%m/%d/%Y %I:%M:%S %p"$><MTEntryIfTagged>
-TAGS: <MTEntryTags include_private="1" glue=","><$MTTagName quote="1"$></MTEntryTags></MTEntryIfTagged>
+DATE: <$MTEntryDate format="%m/%d/%Y %I:%M:%S %p"$>
-----
BODY:
<$MTEntryBody convert_breaks="0"$>
@@ -502,29 +501,6 @@
EXCERPT:
<$MTEntryExcerpt no_generate="1" convert_breaks="0"$>
-----
-KEYWORDS:
-<$MTEntryKeywords$>
------
-<MTComments>
-COMMENT:
-AUTHOR: <$MTCommentAuthor strip_linefeeds="1"$>
-EMAIL: <$MTCommentEmail strip_linefeeds="1"$>
-IP: <$MTCommentIP strip_linefeeds="1"$>
-URL: <$MTCommentURL strip_linefeeds="1"$>
-DATE: <$MTCommentDate format="%m/%d/%Y %I:%M:%S %p"$>
-<$MTCommentBody convert_breaks="0"$>
------
-</MTComments>
-<MTPings>
-PING:
-TITLE: <$MTPingTitle strip_linefeeds="1"$>
-URL: <$MTPingURL strip_linefeeds="1"$>
-IP: <$MTPingIP strip_linefeeds="1"$>
-BLOG NAME: <$MTPingBlogName strip_linefeeds="1"$>
-DATE: <$MTPingDate format="%m/%d/%Y %I:%M:%S %p"$>
-<$MTPingExcerpt$>
------
-</MTPings>
--------
TEXT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment