I solved this issue!
The actual XML data actually does include the line feeds in the description text, encoded as either a HEX 0A (newline) or HEX 0D0A at the end of each line. You can see an example of this in this XML file for the user FastLaneDaily, and it clearly shows the line feeds existing in the text of the descriptions.
There is no reason the line feeds or carriage returns can't be preserved. The only time they are missing in the youtube XML data is if you do a query for a single video. But in the query for a list of videos from a user, the data is there.
Take a look and you'll see it:
http://gdata.youtube.com/feeds/api/user … rt-index=1
Before I made this fix, when I would run "automatic youtube video posts" the line feeds would be removed and replaced with nothing, so the lines run together.
For example, if the XML file shows
<media:description type='plain'>This is the
description
for the post.</media:description>
My resulting text is:
This is thedescriptionfor the post.
After an exhaustive search through all of the code, I found the bug causing this issue.
Perhaps ternstyle can take a look at this and see if there could be a better solution, but at least this works for now! Maybe there is some error conditions that should be handled, but I'm happy at least the lines don't run together now in my wordpress postings.
In the class directory, there is a file called xml.php which was written by Matthew Praetzel.
In this file, there is a function called parse()
parse() sets up the requirements for the PHP xml parser functions. One of these requirements
is to define a function that will parse the characters in the xml stream.
parse() sets this up in this line of code:
xml_set_character_data_handler($this->parser,'parse_item');
This means that the function parse_item() will be used to parse each character of the xml file from youtube.
I've found that it's the first two lines in the parse_item() function that cause the problem. If you change the
first line and comment out the 2nd line, the carriage returns and line feeds are preserved in Wordpress!!!!
so here's what you do:
in the file xml.php change the function parse_item($p, $v)
FROM:
$this->parsed_value = strval(ltrim(rtrim($v,"\t\r\n"),"\t\r\n"));
if($this->parsed_value === '' or empty($this->parsed_value) or preg_match("/^[\s]+$/",$this->parsed_value)) {
return;
}
TO:
// $this->parsed_value = strval(ltrim(rtrim($v,"\t\r\n"),"\t\r\n"));
$this->parsed_value = $v;
// This is the line of code stripping off the CR or CRLF
// if($this->parsed_value === '' or empty($this->parsed_value) or preg_match("/^[\s]+$/",$this->parsed_value)) {
// return;
// }
Last edited by ternstyleuser (2012-01-21 17:32:07)