WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 5 months 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: normal Version: 3.2.1
Component: Import Keywords: close
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 (2)

core.trac.wordpress.org-ticket-16147.patch (429 bytes) - added by gene1wood 4 years ago.
Patch to fix this bug
core.trac.wordpress.org-ticket-16147.2014.patch (406 bytes) - added by gene1wood 6 months ago.
Updated patch against SVN rev 893863

Download all attachments as: .zip

Change History (12)

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 @gene1wood4 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.

@gene1wood4 years ago

Patch to fix this bug

comment:6 follow-up: @chriscct76 months ago

  • Keywords reporter-feedback added
  • Severity changed from major to normal

@novasource: Can you verify this still exists?

comment:7 in reply to: ↑ 6 @novasource6 months ago

Replying to chriscct7:

@novasource: Can you verify this still exists?

Sorry, this was during a major switch from Movable Type a few years ago. We no longer have Movable Type content to migrate, so I can't test.

comment:8 @chriscct76 months ago

  • Keywords close added; reporter-feedback removed

Yeah, I'm not sure what we're going to do with all these old importer tickets now that none of them are in core anymore. Will mark as close, and ask about this at the next core team irc meetup next week

comment:9 @gene1wood6 months ago

@chriscct7 I can confirm that this problem hasn't been fixed as of
Movable Type and TypePad Importer v0.5-beta which is the upcoming version.

Here is the line that causes the bug :

https://plugins.trac.wordpress.org/browser/movabletype-importer/trunk/movabletype-importer.php#L483

I'll attach an updated patch against the head of the repo. Just gotta get it applied and this bug goes away.

@gene1wood6 months ago

Updated patch against SVN rev 893863

comment:10 @ircbot5 months ago

This ticket was mentioned in IRC in #wordpress-dev by chriscct7. View the logs.

Note: See TracTickets for help on using tickets.