summaryrefslogtreecommitdiffstats
path: root/expo
diff options
context:
space:
mode:
authorsubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 05:18:26 +0100
committersubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 05:18:26 +0100
commitf5ddbafcb0899d2c95d8512b1316eaeeee9bedab (patch)
treed8186e9c66191da57bc7bec0f5ffe63e835f5445 /expo
parent13d44fe647b6929137ee4f7d18ba407b8ebaa05a (diff)
downloadtroggle-f5ddbafcb0899d2c95d8512b1316eaeeee9bedab.tar.gz
troggle-f5ddbafcb0899d2c95d8512b1316eaeeee9bedab.tar.bz2
troggle-f5ddbafcb0899d2c95d8512b1316eaeeee9bedab.zip
[svn] Wiki_markup imporved to include paragraphs
wiki_to_html should be used when the field will include paragraphs wiki_to_html_short should be used when the field will not include paragraphs Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8061 by julian @ 11/6/2008 11:24 PM
Diffstat (limited to 'expo')
-rw-r--r--expo/templatetags/wiki_markup.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/expo/templatetags/wiki_markup.py b/expo/templatetags/wiki_markup.py
index 7634485..e2a9d7e 100644
--- a/expo/templatetags/wiki_markup.py
+++ b/expo/templatetags/wiki_markup.py
@@ -34,6 +34,17 @@ def wiki_list(line, listdepth):
@register.filter()
@stringfilter
def wiki_to_html(value, autoescape=None):
+ #find paragraphs
+ outValue = ""
+ for paragraph in re.split("\n\s*?\n", value, re.DOTALL):
+ outValue += "<p>"
+ outValue += wiki_to_html_short(paragraph, autoescape)
+ outValue += "</p>\n"
+ return mark_safe(outValue)
+
+@register.filter()
+@stringfilter
+def wiki_to_html_short(value, autoescape=None):
if autoescape:
value = conditional_escape(value)
#deescape doubly escaped characters
@@ -42,9 +53,11 @@ def wiki_to_html(value, autoescape=None):
value = re.sub("&#39;&#39;&#39;&#39;([^']+)&#39;&#39;&#39;&#39;", r"<b><i>\1</i></b>", value, re.DOTALL)
value = re.sub("&#39;&#39;&#39;([^']+)&#39;&#39;&#39;", r"<b>\1</b>", value, re.DOTALL)
value = re.sub("&#39;&#39;([^']+)&#39;&#39;", r"<i>\1</i>", value, re.DOTALL)
+ #make cave links
+ value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="/troggle/cave/\1/">\1</a>', value, re.DOTALL)
#Make lists from lines starting with lists of [stars and hashes]
- listdepth = []
outValue = ""
+ listdepth = []
for line in value.split("\n"):
t, listdepth = wiki_list(line, listdepth)
outValue += t