Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a problem with using my new blog RSS feed. I wrote a post (the first one) with some code examples formatted by SyntaxHighlighter. To paste a code sample I'm switching from WYSIWYG to HTML view and put the code inside pre tag like this (don't worry, h4 tag was opened a line above the screenshot area):

formatting code example on the blog

The problem is that such pre tag, when later accessed via RSS feed contains br tags instead of new line characters. Below is screenshot of the adequate RSS source code:

RSS source code with unwanted BRs

What's most important when accessed via www, the post html is formatted fine, no brs inside pre. I verified that by downloading the blog post with wget. So I believe this isn't SyntaxHighlighter issue nor any 'new line' formatting on blog post save.

This is a real problem as I want aggregate my blog on employers blog and all formatting of code examples is broken because of that.

The base question is: how to get rid of those unwanted brs served via RSS?

What's strangest friend of mine also uses blogger for such aggregation and he has no such issue. I checked his RSS feed and there are no brs inside pre tags. We also compared settings of our blogs. However we have found no clue.

Last thing: I see content served from RSS is now also html encoded. If I remember well, it wasn't previously.

UPDATE: I found no solution for this issue nor help anywhere. So I've written short PHP script to filter the feed source. Someone may find it useful so here it is:

<?php
$url = 'http://blog.tamashumi.com/feeds/posts/default';
$pre_pattern = '/(\&lt;pre.*?"\&gt;)(.*?)(\&lt;\/pre\&gt;)/';
$br_pattern = '/\&lt;br \/\&gt;/';

function br2nl($match) {
    global $br_pattern;
    $nobrs = preg_replace($br_pattern, "\n", $match[2]);
    return "$match[1]$nobrs$match[3]";
}

$content = file_get_contents($url);
$content = preg_replace_callback($pre_pattern, 'br2nl', $content);

header('Content-type: application/atom+xml');
echo preg_replace($br_pattern, "&lt;br/&gt;\n", $content); // adding NLs
?>

A result of filtered feed can be obtained under the URL. On the first look it doesn't differ, the source does though.

Last thing to mention. I found that blogger had some time ago 'convert line breaks' flag among configuration settings. It's replaced now by new post-level settings:

enter image description here

I believe that my friends blog works as expected because it had the 'convert line breaks' flag set before it disappeared from the configuration panel and probably as a global setting it has influence also on the RSS. Those new post-level settings doesn't affect RSS feed anyhow. Well, that's only an assumption but I have found no other clue for this inconsistency...

share|improve this question

migrated from superuser.com Oct 8 '12 at 16:47

This question came from our site for computer enthusiasts and power users.

    
Hi @topr, since you have solved this issue yourself, would you be able to post it as an answer, instead of in the question text? You are allowed to answer (and mark as best) your own questions. –  DisgruntledGoat Dec 17 '13 at 20:38
    
It's rather hack than "best solution" and involves using external service (hosting for php). Of course I may post it, but haven't even confirmed that anyone else is affected with such problem. Do you think my 'solution' will be helpful? –  topr Dec 18 '13 at 22:54
add comment

1 Answer 1

The RSS entry shouldn't be made into the HTML editor page. It should be made into the default post editor.

OR

There is an option the right panel to choose tag for line break. All you have to do is to untick it.

share|improve this answer
    
You mean those options? i.stack.imgur.com/j4Ffs.png There is no options combination which would alter the issue I'm talking about. –  topr Oct 1 '13 at 13:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.