We’ve moved a couple of clients from older Moveable Type installations to Wordpress and each time Wordpress doesn’t handle the text paragraph formating from the Moveable Type import file. Here is a quick script we created to convert the BODY and EXTENDED BODY sections of the Moveable Type import file to HTML paragraph formatting.
<?php
// TODO: change this to your Moveable Type import filename $filename = "import.txt"; $inBodyOrExtendedBody = false; $output = array();
foreach (explode("\n", file_get_contents($filename)) as $line) {
if ($inBodyOrExtendedBody) {
$inBodyOrExtendedBody = ($line != "-----");
if (!$inBodyOrExtendedBody)
$output[] = "</p>";
}
if ($inBodyOrExtendedBody) {
if (trim($line) == "") {
$output[] = "</p>";
$output[] = "<p>";
}
else
$output[] = $line . "<br/>";
}
else {
$output[] = $line;
$inBodyOrExtendedBody = ($line == "BODY:") ||
($line == "EXTENDED BODY:");
if ($inBodyOrExtendedBody)
$output[] = "<p>";
}
}
// remove the trailing <br/> before </p>
// and the empty paragraphs before outputing
echo str_replace("<br/>\n</p>", "\n</p>",
str_replace("<p>\n</p>", "",
implode("\n", $output)));
?>
Leave a Reply
Copyright © 2010 Tierra Innovation, Inc.
|
RSS | Client Login