Htmltotext written by Aaron is very nice but it generate markdown format. You can hook into the code to disable image and html reference that are added at the end of the conversion.
here is the link: http://www.aaronsw.com/2002/html2text/ Regards, Krish http://www.stacked.in On Aug 25, 9:14 pm, Eric Rasmussen <[email protected]> wrote: > I don't think anyone mentioned the re module yet, so here's a simple > solution I've been using: > > import re > def strip_tags(content): > tags = re.compile('<.*?>', re.DOTALL) > return tags.sub('', content) > > Note that if you have content like '5 < <p> 10', the above function will > strip '< <p>'. If you only want to remove the <p> tag, you can use this: > > import re > def strip_tags(content): > return re.sub('<[^<]*?>', '', content) > > On Wed, Aug 25, 2010 at 8:33 AM, Brian O'Connor <[email protected]> wrote: > > I used stripogram, which I thought worked pretty well. > > > On Wed, Aug 25, 2010 at 11:27 AM, Matthew Hoopes <[email protected] > > > wrote: > > >> On Wed, Aug 25, 2010 at 11:13 AM, Lawrence Oluyede <[email protected] > >> > wrote: > > >>> On Wed, Aug 25, 2010 at 5:06 PM, Dobrysmak <[email protected]> > >>> wrote: > >>> > As in the title. How to strip HTML tags in a string in Pylons? > > >>> You can do it using my module > >>>http://www.oluyede.org/files/htmlstripper.py > > >>> import htmlstripper > >>> print htmlstripper.stripHTML("<HTML>ABBBBB</HTML>", 'ascii') > >>> 'ABBBBB' > > >>> HTH > > >>> -- > >>> Lawrence Oluyede > >>> [eng]http://oluyede.org-http://twitter.com/lawrenceoluyede > >>> [ita]http://www.neropercaso.it > >>> [flickr]http://www.flickr.com/photos/rhymes > > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "pylons-discuss" group. > >>> To post to this group, send email to [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]<pylons-discuss%[email protected]> > >>> . > >>> For more options, visit this group at > >>>http://groups.google.com/group/pylons-discuss?hl=en. > > >> This might also help (answer uses beautiful soup...) > > >>http://stackoverflow.com/questions/753052/strip-html-from-strings-in-... > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "pylons-discuss" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]<pylons-discuss%[email protected]> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/pylons-discuss?hl=en. > > > -- > > Brian O'Connor > > > -- > > You received this message because you are subscribed to the Google Groups > > "pylons-discuss" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<pylons-discuss%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
