Commits

David Chambers committed bb2c173

Tweaked the regular expressions responsible for matching excerpts and updates.

  • Participants
  • Parent commits 5672ab9

Comments (0)

Files changed (1)

 from django.template import Context, loader
 from mango.settings import *
 
-pipe_block = (
-	r'(?m)(^',
-	r'(?=[ \n\r])[^\n\r]*([\n\r]|$))+',
-)
-pipes = (
-	r'(?m)^',
-	r'(?=[ \n\r]) ?',
-)
+block = [r'(?m)^(', r'(?=[ \n\r])[^\n\r]*(\r?\n|$))+']
+match = [r'(?m)^', r'(?=[ \n\r]) ?']
 
 RE = {
 	'replacements': (
 	'heading':       re.compile(r'(?m)\s*<(h[1-6])[^>]*>(?P<title>.+?)</\1>$(?P<html>[\s\S]*)'),
 
 	# excerpts
-	'hand-crafted':  re.compile(r' {,3}\S+:.*((\r\n?|\n)[ \t]*\S+:.*)*(\r\n?|\n){2,}(?P<excerpt>(\|(?=[ \n\r])[^\n\r]*(\r\n?|\n))+)'),
-	'excerpt':       re.compile(r'%s\|%s' % (pipe_block[0], pipe_block[1])),
-	'excerpt_pipes': re.compile(r'%s\|%s' % (pipes[0], pipes[1])),
+	'hand-crafted':  re.compile(r' {,3}\S+:.*(\r?\n[ \t]*\S+:.*)*\r?\n{2,}(?P<excerpt>(\|(?=[ \n\r])[^\n\r]*\r?\n)+)'),
+	'excerpt':       re.compile(r'\|'.join(block)),
+	'excerpt_pipes': re.compile(r'\|'.join(match)),
 
 	# updates
-	'update':        re.compile(r'%s\|\|%s' % (pipe_block[0], pipe_block[1])),
-	'update_pipes':  re.compile(r'%s\|\|%s' % (pipes[0], pipes[1])),
+	'update':        re.compile(r'\|\|'.join(block)),
+	'update_pipes':  re.compile(r'\|\|'.join(match)),
 
 	# {{ filesize }} following internal links
 	'ref-style':     re.compile(r'(\[(?P<id>[^\]]+)\]\s*){{\s*filesize\s*}}'),