Saturday, May 22, 2010

Fixing your feed part 1

For Short feeds only.

I built the Short pipe for this hack to work on blog feeds that have been limited to the first 255 characters or so. It assumes no more than nine paragraphs or so.

That should be plenty if you set your feed options to "short."

However, even a Short feed could theoretically have more than nine paragraphs in a post. If you have a post with lots of really short paragraphs at the beginning--perhaps a list of eight or more short items with line breaks in between--then you may see see some paragraphs run together with no line breaks between them.

I do think this is unlikely, but it is possible.

If your feed is missing some line returns even after it has gone through the Short pipe--and if you've already followed my advice about trailing spaces--and if your pipe catches the first nine returns or so but then fails--then this post is for you.

You can skip to the next post if that doesn't apply to you. Otherwise, go back to Yahoo Pipes, log into your Yahoo account if needed, click "My Pipes," then on the pipe, then on "Edit Source" and scroll down the page.

You should have copied my pipe in your own Pipes account and already be using that to generate the feed for your script.

If you skipped this step you'll have to do it now and then repeat some steps, pasting a script based on the copy into your blog. (Any CSS formatting you may have done is still good, though.)

What you are looking for is a module called "Loop" containing another module called "String Regex" that in turn lists eight "replace" operations for a single quotation mark.
This pipe will handle up to four quotes per post--four words or phrases or paragraphs bracketed by quotation marks. If any of the posts in your feed have more quotes than that, you need to add more "replace" instructions to this module. Here's how.

First, determine how many quotations per post you'll have. Overestimate. Then subtract four (which are accounted for) and multiply by two.

Click the + Rules button to add new Replace lines to the module. You'll need to add two Replace lines for every quote, so if you need another 20, add 40.

Fill the empty Replace fields with a quotation mark, and the empty "With" fields with the alternating pattern @@1@ and @@2@, beginning with @@1@. Yo can copy and paste, but be sure to do so in the right order, 1-2, 1-2, 1-2 & etc.

Why are we screwing around with these quotes? Quotation marks have some unusual syntax and might get messed up by some of the other things we are doing in this pipe later. Consequently we are replacing them with these oddball character strings for now. We'll restore them later.
The next module is another Loop/String Regex deal, but instead of searching for a quotation mark the"Replace" field is a string of typographical characters:([,.;:!?)*])([A-Za-z(]). In the language of normal expressions, this translates into "find any of the following followed by any alphabetical character OR open-parenthesis: a comma OR a period OR a semicolon OR a colon OR an exclamation point OR a close-parenthesis OR an asterisk." It would find, for instance, the "!P" in
Welcome to my blog!Please stop and smell the javascript.
and would stick some line returns in there.

All you might need to do is to add more lines to this module and populate the blanks with the codes from the filled lines, using copy and paste. The codes are the same for each line, and each line adds a return once per blog post.

The next Loop/Regex Module does a similar thing for quotes that end a paragraph.
As you can see, there are two different patterns here. You will need to add as many new lines as you did for the quotations in the first Loop/Regex module, and turn them into duplicates (copy and paste works great) of the two patterns en exactly equal numbers. If you add ten lines, make it five of each. The order does not matter.

(Actually you probably don't need to add that many new lines. What you really need to add are enough new lines, in pairs, to equal the most quotes that end a paragraph in the first 255 characters of any of your blog posts.)

Taking care of the quotes is probably the most cross-eye-making part of this whole operation. If you don't make enough new replace lines, or if you decide to skip this step, the worst thing that will happen is that you may find that some paragraphs ending with quotes are missing their line returns in the first-post-first feed you publish on your blog.

There is one more step you should take--a little easier I think--to perfect that feed.

No comments:

Post a Comment