Added precompiled regexp for commentfile parsing
This commit is contained in:
parent
c4b4c138c2
commit
59b3fe4272
12
blogthon.cgi
12
blogthon.cgi
@ -23,6 +23,8 @@ import ConfigParser
|
||||
|
||||
# A wonderful place for doing some regexp ;)
|
||||
no_break = re.compile('^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</tr>|<td|</td>|<th|</th>|<p|</p>).*$')
|
||||
line_start_hyphen = re.compile('^-.*$')
|
||||
line_start_plus = re.compile('^\+.*$')
|
||||
|
||||
def generate_uuid(string):
|
||||
string_md5sum = md5.new(string).hexdigest()
|
||||
@ -409,6 +411,7 @@ else:
|
||||
|
||||
print ' <div class="entries">'
|
||||
print ''
|
||||
|
||||
# Staticpage
|
||||
if static_display != "":
|
||||
content = open(staticpages_dir + static_display, "r")
|
||||
@ -417,7 +420,7 @@ else:
|
||||
print ' <div class="entry_content">'
|
||||
print ' <p>'
|
||||
for line in content:
|
||||
if re.match(no_break, line):
|
||||
if no_break.match(line):
|
||||
print ' ' + line.strip()
|
||||
else:
|
||||
print ' ' + line.strip() + '<br />'
|
||||
@ -431,6 +434,7 @@ else:
|
||||
print ' </div>'
|
||||
print ''
|
||||
content.close()
|
||||
|
||||
# Entry
|
||||
else:
|
||||
entry_counter = 0
|
||||
@ -453,7 +457,7 @@ else:
|
||||
print ' <div class="entry_date">' + date + '</div>'
|
||||
print ' <div class="entry_content">'
|
||||
for line in content:
|
||||
if re.match(no_break, line):
|
||||
if no_break.match(line):
|
||||
print ' ' + line.strip()
|
||||
else:
|
||||
print ' ' + line.strip() + '<br />'
|
||||
@ -480,7 +484,7 @@ else:
|
||||
label_count = 0
|
||||
|
||||
for line in comments_content:
|
||||
if re.search("^-", line):
|
||||
if line_start_hyphen.match(line):
|
||||
if notfirstline == 1:
|
||||
print ' </div>'
|
||||
print ' </div>'
|
||||
@ -492,7 +496,7 @@ else:
|
||||
print ' <a name="' + str(label_count) + '"></a>'
|
||||
|
||||
print ' <div class="comment_author">' + line.split(".", 1)[1].strip() + '</div>'
|
||||
elif re.search("^\+", line):
|
||||
elif line_start_plus.match(line):
|
||||
print ' <div class="comment_date">' + line.split(".", 1)[1].strip() + '</div>'
|
||||
print ' <div class="comment_content">'
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user