Support » Fixing WordPress » Importing from Movable Type: No Hard Returns

  • Hello all –

    I’m in the process of setting up my blog using WordPress (migrating from Movable Type). I was able to import all of my entries no problem, but I’m noticing that many of the hard returns don’t seem to have carried over.

    Specifically, when I view posts via WordPress… I can tell were paragraphs end/begin, but there’s no space between paragraphs. It’s as though a single hard return registered, but the second hard return did not.

    In cracking open the MT export file (just a .txt file), I see that the hard returns are present in the exported file. No <p> tags or
    tags, just hard returns.

    In the MT exported .txt file, the entry text looks like this:

    So now that we’re living in different cities, Matt and I have taken to chatting using MSN. We decided on making Friday a general deadline, with us swapping poems once a week. No critique, no pressure to comment. Just exchanging poems for no other reason than an arbitrary deadline to get us motivated and producing.

    I’m spending most of today working on a portfolio redesign. But before tomorrow, I should have another poem to send off. Below is the poem I swapped with Matt, last week.

    But when viewed via WordPress, the entry text looks like this:

    So now that we’re living in different cities, Matt and I have taken to chatting using MSN. We decided on making Friday a general deadline, with us swapping poems once a week. No critique, no pressure to comment. Just exchanging poems for no other reason than an arbitrary deadline to get us motivated and producing.
    I’m spending most of today working on a portfolio redesign. But before tomorrow, I should have another poem to send off. Below is the poem I swapped with Matt, last week.

    At this point, my options are:

    1) Revisit MT and try to export data out with <p> and
    tags.

    I’ve looked, and there doesn’t seem to be anything other than a big “export” button. I’ve verified that my text formatting settings are set to “convert line breaks.”

    2) Figure out some way for WordPress to recognize the hard returns – or at least, the second hard return.

    Not sure if this is a WordPress issue, but given that I’m at a dead end with the MT export, this seems like the next best option.

    3) Run GREP patterns sweeps on my exported .txt file and insert any necessary <p> or
    tags for every entry.

    I can do this, but I really, really don’t want to. I’ve been keeping a daily blog for about 6 years now, and have about 6,000 entries all in all. It’s not that I’m unwilling to roll up my sleeves and do the dirty work – I just an hoping there’s another approach that I may not know of.

    Any and all advice/thoughts appreciated. Figuring out this issue would translate into a huge leap in my migration process.

    Cheers!
    -Felix

Viewing 7 replies - 1 through 7 (of 7 total)
  • I noticed something that might be related. In my exported MT text file, I see this:

    ——–
    AUTHOR: avoision
    TITLE: This Week’s Assignment is…
    BASENAME: this_weeks_assignment_is
    STATUS: Publish
    ALLOW COMMENTS: 1
    CONVERT BREAKS: __default__
    ALLOW PINGS: 1
    DATE: 07/04/2002 12:00:01 AM
    —–

    Is it possible that there’s some other value I can change the CONVERT BREAKS line to, so that WordPress will pick up both hard returns in my entry bodies?

    Again, WP seems to be picking up a singular hard return… but not in cases where I have more than one.

    I’m dusting off my regular expression chops, but would still love some other option than running multiple find/replace passes…

    I, too, am searching for a solution to this exact issue, as I just migrated one of our company blogs from Movable Type to WordPress 2.7.1 this morning…

    All of the hard returned line breaks made in the Movable Type editor (that show up with both opening and closing <p> tags in the MT source code) have been converted to
    tags at the end of each paragraph in the WordPress source code, rendering only a soft return.

    Overall, the export / import process was extremely quick and easy, but I’ve now spent all afternoon researching this one little paragraph formatting snag, and haven’t been able to come up with an efficient solution.

    With daily posts dating back to 2004, a “find and replace hardcoding” solution is not at the top of my options list. I’d love to hear some other ideas for potential fixes!

    Hi there!

    What I did was changing

    CONVERT BREAKS: __default__

    to

    CONVERT BREAKS: 0

    Let me know whether it works for you too.

    I’ve had the same problem, and have solved it by editing the MT import file. (I’ve submitted a bug, and a patch, on Trac.)

    You need to open the file wp-admin/import/mt.php, go to line 442, and you will find the following:

    if( !empty($line) )
      $line .= "\n";

    You need to insert this code, under those two lines:

    if( empty($line) ) {
       if ( 'body' == $context )
         $line .= "\n";
       if ( 'extended' == $context )
         $line .= "\n";
       if ( 'comment' == $context )
         $line .= "\n";
       if ( 'excerpt' == $context )
         $line .= "\n";
       }

    So, it preserves the newlines when the context is relevant, and discards them otherwise.

    IndigoJo — This worked great for me, thanks! The only issue I found was that for completely empty fields, this will insert a ‘\n’ character. In particular, this breaks the auto-generated 55-word excerpts, because the excerpt is now considered non-empty. I fixed this by editing wp-includes/formatting.php, line 1483 (in wp_trim_excerpt). I changed:

    if ( '' == $text) {

    to

    if ( '' == trim($text)) {

    and now the excerpts show up.

    Re-saving an entry also fixes it, but I didn’t want to do that with all 800 imported entries. 🙂

    @indigojo – Great job. Worked like a charm going from MT 3.3ish to 2.8ish WP.

    @shashachu – I had the same problem but your edit did not fix it. After the import I edited the mysql table with a REPLACE command to erase any “\n” in the post_excerpt field.

    Update wp_posts set ‘post_excerpt’ = replace(‘post_excerpt’, ‘\n’, ”)

    I found another solution for this problem here. It looks simpler than the other ones suggested here and it worked for me 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Importing from Movable Type: No Hard Returns’ is closed to new replies.