WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#16147 reopened defect (bug)

MT Importer truncates double vertical spaces, munging paragraphs together

Reported by: novasource Owned by:
Milestone: WordPress.org Priority: normal
Severity: major Version: 3.2.1
Component: Import Keywords:
Focuses: Cc:

Description

Movable Type 3.x-era exports don't use <p> tags. Like TinyMCE (and WordPress), a <p> in final rendered code is represented by two \ns in a row.

The importer strips out double \ns and replaces with a single \n. This causes paragraphs to lose their distinction upon import.

It does this because the $line variable was created by $line = $this->fgets($handle) (line 339). Then $line = trim($line) (line 340) strips out several characters, including \n.

Lines 455 and 456 add back the \n except on blank lines:

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

So if a $line was nothing but a \n, it's stripped by the trim function and becomes a 0 character line. Then the if( !empty($line) ) declines to add back a \n.

Somehow this needs to be altered so that successive \ns aren't stripped. Otherwise paragraphs get vertically munged together.

Attachments (1)

core.trac.wordpress.org-ticket-16147.patch (429 bytes) - added by gene1wood 3 years ago.
Patch to fix this bug

Download all attachments as: .zip

Change History (6)

comment:1 novasource4 years ago

Just confirmed that deleting line 455 (if( !empty($line) )) fixed everything for me. Now the \n is restored to the end of every line.

I could see it being prudent, as a cleanup step, to remove any trailing \ns from the post_content, extended, post_except, post_keywords, and comment_content values for good measure.

Reference http://wordpress.org/support/topic/plugin-movable-type-and-typepad-importer-movable-type-importer-messes-up-line-spacing for a forum post.

Version 0, edited 4 years ago by novasource (next)

comment:2 garyc404 years ago

  • Resolution set to invalid
  • Status changed from new to closed

I think you should post this ticket (and #16148) in the plugins trac instead of core trac.

http://plugins.trac.wordpress.org/newticket

Choose MT Importer from the list of Components.

comment:3 ocean904 years ago

  • Milestone Awaiting Review deleted

comment:4 duck_4 years ago

  • Milestone set to WordPress.org
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version 3.0.4 deleted

This is currently the correct venue for the official importers which were recently moved to plugin repo.

Still needs review to confirm bug.

comment:5 gene1wood3 years ago

  • Version set to 3.2.1

I can confirm that this bug is present in Wordpress 3.2.1. I imported a Movable Type blog which contained sections like the following in the mt-export.txt file :

...
-----
BODY:
So The Lad sent me another one of my pieces--even from Munich he comes to my rescue. Thanks love.

My biggest fear right now is that I might run into the Sicilian on campus somewhere and not have a biting remark ready to hand. If any of you have suggestions, I welcome them.

See, I need to keep the scary rage in place because it helps me get out of bed in the morning.
-----
...

The double carriage returns were turned into single carriage returns which causes Wordpress to render each of these as sentences with a <br> tag at the end instead of paragraphs.

I fixed this by following the suggestions I found here : http://onalark.livejournal.com/192394.html
The comments in this entry that suggest changing the "CONVERT BREAKS" values in the mt-export.txt file are incorrect. This is not needed.

I'm attaching a patch which fixes this bug and worked for me.

gene1wood3 years ago

Patch to fix this bug

Note: See TracTickets for help on using tickets.