summaryrefslogtreecommitdiffstats
path: root/wiki/templatetags/wikitags.py
diff options
context:
space:
mode:
authorDusty Phillips <buchuki@gmail.com>2008-10-06 03:47:58 +0200
committerDusty Phillips <buchuki@gmail.com>2008-10-06 03:47:58 +0200
commitb35117b36895756571a23c71b3379a4c2efa06e4 (patch)
tree5f11f524c13bc40ae31aefdbcc4b20e7d1c65b4d /wiki/templatetags/wikitags.py
parent103d1a347a7515c67af7dbd3241a4970dd46faac (diff)
downloadarchweb-b35117b36895756571a23c71b3379a4c2efa06e4.tar.gz
archweb-b35117b36895756571a23c71b3379a4c2efa06e4.tar.xz
drop references to the wiki
Diffstat (limited to 'wiki/templatetags/wikitags.py')
-rw-r--r--wiki/templatetags/wikitags.py60
1 files changed, 0 insertions, 60 deletions
diff --git a/wiki/templatetags/wikitags.py b/wiki/templatetags/wikitags.py
deleted file mode 100644
index da662e8..0000000
--- a/wiki/templatetags/wikitags.py
+++ /dev/null
@@ -1,60 +0,0 @@
-from django.template import Library
-from django.conf import settings
-from archweb_dev.main import markdown
-import re
-
-register = Library()
-
-class WikiProcessor:
- def run(self, lines):
- in_table = False
- for i in range(len(lines)):
- # Linebreaks
- lines[i] = re.sub("%%", "<br />", lines[i])
- # Internal Links
- lines[i] = re.sub("\(\(([A-z0-9 :/-]+)\)\)", "<a href=\"/wiki/\\1\">\\1</a>", lines[i])
- # Small Text
- lines[i] = re.sub("----([^----]+)----", "<span style=\"font-size:x-small\">\\1</span>", lines[i])
- lines[i] = re.sub("--([^--]+)--", "<span style=\"font-size:small\">\\1</span>", lines[i])
- # TT text
- lines[i] = re.sub("\{\{([^}\}]+)\}\}", "<tt>\\1</tt>", lines[i])
- # Tables
- m = re.match("(\|\|)", lines[i])
- if m:
- count = len(re.findall("(\|\|+)", lines[i]))
- first = True
- m2 = re.search("(\|\|+)", lines[i])
- while m2 and count:
- count -= 1
- colspan = len(m2.group(1)) / 2
- if first:
- repl = "<td colspan=\"%d\">" % (colspan)
- first = False
- elif count == 0:
- repl = "</td>"
- else:
- repl = "</td><td colspan=\"%d\">" % (colspan)
- lines[i] = re.sub("(\|\|+)", repl, lines[i], 1)
- # find the next chunk
- m2 = re.search("(\|\|+)", lines[i])
- lines[i] = "<tr>" + lines[i] + "</tr>"
- if not in_table:
- lines[i] = "<table>" + lines[i]
- in_table = True
- elif in_table:
- lines[i] = "</table>" + lines[i]
- in_table = False
- # close leftover table, if open
- if in_table:
- lines[len(lines)] = lines[len(lines)] + "</table>"
- return lines
-
-@register.filter
-def wikify(value):
- md = markdown.Markdown(value)
- md.preprocessors.insert(0, WikiProcessor())
- html = md.toString()
- return html
-
-# vim: set ts=4 sw=4 et:
-