Remove \r's.
authorMatthijs Kooijman <matthijs@stdio.flexvps.nl>
Fri, 27 Mar 2009 09:55:29 +0000 (10:55 +0100)
committerMatthijs Kooijman <matthijs@stdio.flexvps.nl>
Fri, 27 Mar 2009 09:55:29 +0000 (10:55 +0100)
tools/templatetags/encode_email.py

index 6a737d1e9c295432cede2d3774c9f76e8410289e..e7dccf66d3982c603bd2463a041587ae4c6b8b96 100644 (file)
@@ -1,52 +1,52 @@
-import random\r
-from django import template\r
-"""\r
-    Randomized string encoding\r
-    Inspired by John Gruber's Markdown: \r
-    http://daringfireball.net/projects/markdown/syntax#autolink\r
-"""\r
-register = template.Library()\r
-\r
-#@template.stringfilter\r
-def encode_string(value):\r
-    """\r
-    Encode a string into it's equivalent html entity.\r
-\r
-    The tag will randomly choose to represent the character as a hex digit or\r
-    decimal digit.\r
-   \r
-    Use {{ obj.name|encode_string }}\r
-    \r
-    {{ "person"|encode_string }} Becomes something like:\r
-    &#112;&#101;&#x72;&#x73;&#x6f;&#110;\r
-    """\r
-    e_string = "" \r
-    for a in value:\r
-        type = random.randint(0,1)\r
-        if type:\r
-            en = "&#x%x;" % ord(a)\r
-        else:\r
-            en = "&#%d;" % ord(a)\r
-        e_string += en \r
-    return e_string\r
-\r
-register.filter("encode_string", encode_string)\r
-\r
-def encode_mailto(value, arg):\r
-    """\r
-    Encode an e-mail address and its corresponding link name to its equivalent\r
-    html entities.\r
-\r
-    Use {{ obj.email|encode_mailto:obj.name }}\r
-    \r
-    {{ "j@j.com"|encode_mailto:"j" }} Becomes something like:\r
-    <a href="&#x6d;&#x61;&#x69;&#x6c;&#x74;&#111;&#x3a;&#106;&#x40;&#106;\\r
-    &#46;&#99;&#x6f;&#x6d;">&#x6a;</a>\r
-    """\r
-    address = 'mailto:%s' % value\r
-    address = encode_string(address)\r
-    name = encode_string(arg)\r
-    tag = "<a href=\"%s\">%s</a>" % (address, name)\r
-    return tag\r
-\r
-register.filter("encode_mailto", encode_mailto)\r
+import random
+from django import template
+"""
+    Randomized string encoding
+    Inspired by John Gruber's Markdown: 
+    http://daringfireball.net/projects/markdown/syntax#autolink
+"""
+register = template.Library()
+
+#@template.stringfilter
+def encode_string(value):
+    """
+    Encode a string into it's equivalent html entity.
+
+    The tag will randomly choose to represent the character as a hex digit or
+    decimal digit.
+   
+    Use {{ obj.name|encode_string }}
+    
+    {{ "person"|encode_string }} Becomes something like:
+    &#112;&#101;&#x72;&#x73;&#x6f;&#110;
+    """
+    e_string = "" 
+    for a in value:
+        type = random.randint(0,1)
+        if type:
+            en = "&#x%x;" % ord(a)
+        else:
+            en = "&#%d;" % ord(a)
+        e_string += en 
+    return e_string
+
+register.filter("encode_string", encode_string)
+
+def encode_mailto(value, arg):
+    """
+    Encode an e-mail address and its corresponding link name to its equivalent
+    html entities.
+
+    Use {{ obj.email|encode_mailto:obj.name }}
+    
+    {{ "j@j.com"|encode_mailto:"j" }} Becomes something like:
+    <a href="&#x6d;&#x61;&#x69;&#x6c;&#x74;&#111;&#x3a;&#106;&#x40;&#106;\
+    &#46;&#99;&#x6f;&#x6d;">&#x6a;</a>
+    """
+    address = 'mailto:%s' % value
+    address = encode_string(address)
+    name = encode_string(arg)
+    tag = "<a href=\"%s\">%s</a>" % (address, name)
+    return tag
+
+register.filter("encode_mailto", encode_mailto)