I started writing my own, but decided I better make sure I'm not
re-inventing the wheel here.
Thanks.
SA
You are probably looking for what has been labelled "Structured Text".
Try a search on google with that and "python"...
-Peter
Sure!
def textToHtml(text):
return '<html><body><pre>%s</pre></body></head>' % text
<wink>
(sorry... couldn't resist)
-- Michael Chermside
import cgi
def textToHtml(text):
return '<html><body><pre>%s</pre></body></html>' % cgi.escape(text)
><wink>
<wink/>
>(sorry... couldn't resist)
Neither could I. :)
Andrew
da...@dalkescientific.com
> <wink/>
>
> >(sorry... couldn't resist)
>
> Neither could I. :)
Ah, but that's XML, not HTML. :-)
--
Erik Max Francis / m...@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Who'd ever think it / Such a squalid little ending
\__/ The American and Florence, _Chess_
Church / http://www.alcyone.com/pyos/church/
A lambda calculus explorer in Python.
Try reStructuredText, part of Docutils (URLs below).
--
David Goodger <goo...@users.sourceforge.net> Open-source projects:
- Python Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)
- The Go Tools Project: http://gotools.sourceforge.net/
>> <wink/>
>>>(sorry... couldn't resist)
>> Neither could I. :)
> Ah, but that's XML, not HTML. :-)
Of course it might be some future extension to XHTML
Zope has got a StructuredText package that can be used "standalone" (outside
of a Zope site).
Otherwise, here's a simple snip that will help if you want to do it by
yourself : It changes the markup from the original plain text and replaces
against entities and changes http, ftp and mail markups against hyperlinks.
Can be improved of course.
import string, re
# Subtitute HTML markup chars by entities
text = string.replace(text, '&', '&')
text = string.replace(text, '<', '<')
text = string.replace(text, '>', '>')
text = string.replace(text, '\n', '</p>\n<p>')
# Make hyperlinks from HTTP or FTP URLs
pat = re.compile(r'((ftp|http)://[\w-]+(?:\.[\w-]+)*(?:/[\w\-\.?=]*)*)')
text = pat.sub('<a href="\\1">\\1</a>', text)
# Make hyperlinks from email addresses
pat = re.compile(r'([\w-]+(?:\.[\w-]+)*@[\w-]+(?:\.[\w-]+)*)')
text = pat.sub('<a href="mailto:\\1">\\1</a>', text)
HTH
--Gilles
"James T. Dennis" <jade...@idiom.com> a écrit dans le message news:
aempf6$1nq2$1...@news.idiom.com...