{% macro rule_head() -%} {# #} {%- endmacro %} {% macro rule_tabset(feed_uid, tabs) -%}
{% for initial, rules in tabs|dictsort %} {% if initial != 'Python' %}
{% for uid, rtype, expires, text in rules %} {% if feed_uid %} {% else %} {% endif %} {% endfor %}
RuleTypeTextFiltered articles Delete
{{ uid }} {{ rtype }} {{ text }}showshowdelete
{% endif %} {% endfor %} {% if tabs.get('Python') %}
{% for uid, rtype, expires, text in tabs['Python'] %} {% endfor %}
RuleExpiresTextDelete Update
{{ uid }}

Filter syntax:

The filtering rules are Python expressions that are evaluated as booleans. The following variables are always available:

VariableDescription
feed_titleTitle of the feed
titleTitle of the article
title_lcTitle of the article (all in lower case)
title_wordsSet of lower-cased and diacritic-stripped words in the title
contentContents of the article
content_lcContents of the article (all in lower case)
content_wordsSet of lower-cased and diacritic-stripped words in the content
union_lcUnion of the article (all in lower case)
union_wordsSet of lower-cased and diacritic-stripped words in both title and contents
linkarticle URL (before dereferencing)
categoryIf present, set of categories for the article
authorAuthor of the article

In addition, the convenience functions title_any, content_any, union_any, title_any_lc, content_any_lc, union_any_lc, title_any_words, content_any_words, union_any_wordsare here to simplify rules. They take a list of strings and search in the corresponding title|content(|_lc|_words) (the union_* variants will match either title or contents). If any of the strings in the list matches, the function returns True.

The function link_already(url) checks if the URL passed as its argument is that of an article that was already loaded. This is useful to filter out duplicates or echos from aggregated feeds like Digg or Slashdot, but it also slows down feed processing.

Other variables may be available on a feed-by-feed basis, also depending on which feed standard is used (e.g. Atom vs. RSS). Check the feed details page for the feed you are interested in for more details.

If a variable does not exist, the expression evaluation will throw an exception, and the article will not be filtered out, but in a Python logical OR expression, if the first term evaluates true, the second term is not evaluated and the article will be filtered out even if the second term refers to a variable that does not exist.

You can add comments by starting a line with the character #, and use carriage returns like whitespace for legibility

Examples

Should be self-explanatory:

    'Salon' in feed_title and ('King Kaufman' in title or 'Letters' in
    title) 
 'SAP' in title.split()
    

or almost equivalently:

    'sap' in title_words
    
    'Guardian Unlimited' in feed_title and (content.startswith('Sport:')
     or 'football' in content_lc or 'cricket' in content_lc)
    

which is equivalent to:

    'Guardian Unlimited' in feed_title and (content.startswith('Sport:')
    or content_any_lc('football', 'cricket'))
    

Filter articles referring to SAP, but as a word (i.e. do not filter out 'ASAP'):

    union_any_words('sap')
    
{% endif %} {%- endmacro %}