This patch allows for metadata entries in .txtl files.
Example metadata:
title #metakey metavalue entry body text
The patch looks like this:
--- pyblosxom/contrib/entryparsers/txtl.py~ 2004-05-19 11:51:35.000000000 +0200
+++ pyblosxom/contrib/entryparsers/txtl.py 2004-08-16 17:51:49.000000000 +0200
@@ -190,11 +190,22 @@
def readfile(filename, request):
entryData = {}
- d = open(filename).read()
+ d = open(filename).readlines()
- # Grab title and body.
- title = d.split('\n')[0]
- body = d[len(title):]
+ # Grab title
+ entryData['title'] = d.pop(0).strip()
+
+ # this handles properties of the entry that are between
+ # the title and the body and start with a #
+ import re
+ while len(d) > 0:
+ match = re.match(r'^#(\w+)\s+(.*)', d[0])
+ if match:
+ d.pop(0)
+ entryData[match.groups()[0]] = match.groups()[1].strip()
+ else:
+ break
+ body = "\n" + ''.join(d)
# Grab textile configuration.
config = request.getConfiguration()
@@ -205,8 +216,7 @@
body = textile(body, head_offset=head_offset, validate=validate, output=output, encoding=encoding)
- entryData = {'title': title,
- 'body': body}
+ entryData['body'] = body
# Call the postformat callbacks
tools.run_callback('postformat',
The code is based on the standard pyblosxom entry parser for .txt-files.