Add minhead filter, and resync opml-top100.ini

This commit is contained in:
Sam Ruby 2007-06-15 10:42:01 -04:00
parent 2f792f919e
commit b25df8b9d4
4 changed files with 48 additions and 1 deletions

View File

@ -31,13 +31,18 @@ activity_threshold = 90
# filters to be run # filters to be run
filters = excerpt.py filters = excerpt.py
bill_of_materials:
.htaccess
favicon.ico
robots.txt
# filter parameters # filter parameters
[excerpt.py] [excerpt.py]
omit = img p br omit = img p br
width = 500 width = 500
# add memes to output # add memes to output
[index.html.tmpl] [index.html.xslt]
filters = mememe.plugin filters = mememe.plugin
[mememe.plugin] [mememe.plugin]

36
filters/minhead.py Normal file
View File

@ -0,0 +1,36 @@
#
# Ensure that all headings are below a permissible maximum (like h3).
# If not, all heading levels will be changed to conform.
# Note: this may create "illegal" heading levels, like h7 and beyond.
#
import sys
from xml.dom import minidom, XHTML_NAMESPACE
# determine permissible minimimum heading
if '--min' in sys.argv:
minhead = int(sys.argv[sys.argv.index('--min')+1])
else:
minhead=3
# parse input stream
doc = minidom.parse(sys.stdin)
# search for headings below the permissable minimum
first=minhead
for i in range(1,minhead):
if doc.getElementsByTagName('h%d' % i):
first=i
break
# if found, bump all headings so that the top is the permissible minimum
if first < minhead:
for i in range(6,0,-1):
for oldhead in doc.getElementsByTagName('h%d' % i):
newhead = doc.createElementNS(XHTML_NAMESPACE, 'h%d' % (i+minhead-first))
for child in oldhead.childNodes:
newhead.appendChild(child)
oldhead.parentNode.replaceChild(newhead, oldhead)
# return (possibly modified) document
print doc.toxml('utf-8')

View File

@ -0,0 +1,3 @@
[Planet]
filters = minhead.py?min=3
filter_directories = filters

View File

@ -0,0 +1,3 @@
<div xmlns="http://www.w3.org/1999/xhtml">
<h1>title</h1><h3>mid</h3><h5>bottom</h5>
</div>