From 792751b96037dfb6cc6ee46a599774cebddc9abf Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Sun, 12 Jul 2009 05:54:08 +0100 Subject: [PATCH] [svn] Add regex to turn ==headers== into

headers --- core/templatetags/wiki_markup.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/templatetags/wiki_markup.py b/core/templatetags/wiki_markup.py index ec8a997..4cfd78d 100644 --- a/core/templatetags/wiki_markup.py +++ b/core/templatetags/wiki_markup.py @@ -69,7 +69,18 @@ def wiki_to_html_short(value, autoescape=None): value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'\1' % url_root, value, re.DOTALL) #make people links value = re.sub("\[\[\s*person:(.+)\]\]",r'\1' % url_root, value, re.DOTALL) - + #make headers + def headerrepl(matchobj): + number=len(matchobj.groups()[0]) + num=str(number) + if number>1: + return ''+matchobj.groups()[1]+'' + else: + print 'morethanone' + return matchobj.group() + value = re.sub(r"(=+)([^=]+)(=+)",headerrepl,value) + + #make qm links. this takes a little doing qmMatchPattern=settings.QM_PATTERN def qmrepl(matchobj): @@ -85,7 +96,7 @@ def wiki_to_html_short(value, autoescape=None): found_by__date__year = qmdict['year'], number = qmdict['number']) return r'%s' % (qm.get_absolute_url(), qm.code, unicode(qm)) - except QM.DoesNotExist: #bother aaron to make him clean up the below code + except QM.DoesNotExist: #bother aaron to make him clean up the below code - AC try: placeholder=LogbookEntry.objects.get(date__year=qmdict['year'],cave__kataster_number=qmdict['cave'], title__icontains='placeholder') except LogbookEntry.DoesNotExist: