@KelsonV it could be an idea to check the contents of your summary fields' values for HTML, and if they contain HTML, to set type=html for that field too. (Simplest test would probably be to check if it contains <p> I guess)

The w3c validator is currently warning that a summary may not contain HTML unless declared in type attribute.

It also complains about an unexpected p-end tag in the first entry, but I'm not quite sure why...

Anyway, you got yourself a nice solution :D

@FiXato Good idea to check the summary. I'll update that!

I'm curious about that p-end tag too - I think something's probably getting smushed together.

@FiXato Aha - it's the WP plugin I'm using for hiding spoilers. It's putting a div inside of a paragraph.

@KelsonV good catch :)

One final note btw:
while the Atom RFC doesn't seem to say anything about the order of feed items in an Atom feed, your combined feed and for example your Tech Tips feed are inconsistent in their order.
Your combined feed seems to put the oldest entry first, while the Tech Tips feed puts the most recent one first.

Might be something to consider. :)

@FiXato Right, I was going to look up why feedgen is ordering them backwards. Or forwards.

@KelsonV the default for add_entry is 'prepend' apparently:

add_entry(feedEntry=None, order='prepend')
This method will add a new entry to the feed. If the feedEntry argument is omittet a new Entry object is created automatically. This is the preferred way to add new entries to a feed.


feedEntry – FeedEntry object to add.
order – If prepend is chosen, the entry will be inserted at the beginning of the feed. If append is chosen, the entry will be appended to the feed. (default: prepend).

@FiXato Updated! both the script and the article. Thanks again for helping me discover and track down those problems!

code snippets inside 

@KelsonV I think you can simplify your 'contains' check to:

if '<' in item['summary']:

could probably also condense this bit

if (str.__contains__(item['summary'], '<')):
fe.summary(summary=item['summary'], type='html')


summary_type = 'html' if '<' in item['summary'] else None
fe.summary(summary=item['summary'], type=summary_type)

or even:

fe.summary(summary=item['summary'], type=('html' if '<' in item['summary'] else None))

(untested, but I think it would work)

re: code snippets inside 

@KelsonV (see python ternary operator for the 'if else' structure I used for the summary_type.

code snippets inside 

@FiXato Ah, that's very helpful! I've been writing Java forever, but I'm new enough to Python that I didn't even know it *had* a ternary operator!

re: code snippets inside 

@KelsonV one final note, this time regarding your indieweb snippet:
it's recommended to do your file writing in a 'with' block, as per as this helps ensure the file gets closed, even in the event of an exception.

re: code snippets inside 

@FiXato Thanks again for the tips. I've implemented them in my live script and updated the article again!

Sign in to participate in the conversation

On the internet, everyone knows you're a cat — and that's totally okay.