quixote html.py,1.13,1.14

Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]>
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Update of /home/cvs/quixote
In directory hewson:/tmp/cvs-serv30466

Modified Files:
	html.py 
Log Message:
Add nl2br function.


Index: html.py
===================================================================
RCS file: /home/cvs/quixote/html.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- html.py	15 Oct 2002 20:25:56 -0000	1.13
+++ html.py	17 Oct 2002 17:07:12 -0000	1.14
@@ -271,6 +271,15 @@
             htmltext("</a>"))
 
 
+def nl2br (value):
+    """nl2br(value : any) -> htmltext
+
+    Insert <br /> tags before newline characters.
+    """
+    text = htmlescape(text)
+    return htmltext(text.s.replace('\n', '<br />\n'))
+
+
 def url_quote(value, fallback=None):
     """url_quote(value : any [, fallback : string]) -> string
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.