commit 9307ec78336d3c616941c46e4f262119c0f5fca9
parent 8b20da04b78db8c62d5379db4ae5da05bf8aca53
Author: Sam Kingston <sam@sjkwi.com.au>
Date: Sun, 16 Nov 2008 15:00:37 +1000
Pass all entry body content through smartypants
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/blog.py b/blog.py
@@ -1,6 +1,7 @@
import os, re, uuid, email
from datetime import datetime
import genshi
+from smartypants import smartyPants
import yaml
@@ -21,6 +22,10 @@ def cleanup_metadata(header_items):
cleaned[k] = v
return cleaned
+def smartypants_parse(s):
+ return smartyPants(s, attr='2') # attr adds -- and --- support
+
+
IDIFY_WHITESPACE_PATT = re.compile(r'(?u)\s+')
IDIFY_ACCEPT_PATT = re.compile(r'(?u)\w|[-_]')
def idify(s):
@@ -92,7 +97,7 @@ class BlogEntry(object):
# not really a MIME document, but parse it like one
msg = email.message_from_file(open(os.path.join(self.dir, 'content.txt'), 'r'))
self.metadata = cleanup_metadata(msg.items())
- self.body = msg.get_payload().decode('utf8') # XXX encoding
+ self.body = smartypants_parse(msg.get_payload().decode('utf8')) # XXX encoding
self.title = self.metadata['title']
raw_tags = self.metadata.get('tags', '').strip()