diff genshi/util.py @ 659:7aebde54c10f experimental-sandboxed

merged trunk into sandbox branch
author aronacher
date Thu, 29 Nov 2007 18:07:32 +0000
parents 4ad264337a50
children
line wrap: on
line diff
--- a/genshi/util.py
+++ b/genshi/util.py
@@ -228,7 +228,7 @@
                     return ref
     return _STRIPENTITIES_RE.sub(_replace_entity, text)
 
-_STRIPTAGS_RE = re.compile(r'<[^>]*?>')
+_STRIPTAGS_RE = re.compile(r'(<!--.*?-->|<[^>]*>)')
 def striptags(text):
     """Return a copy of the text with any XML/HTML tags removed.
     
@@ -239,6 +239,11 @@
     >>> striptags('Foo<br />')
     'Foo'
     
+    HTML/XML comments are stripped, too:
+    
+    >>> striptags('<!-- <blub>hehe</blah> -->test')
+    'test'
+    
     :param text: the string to remove tags from
     :return: the text with tags removed
     """
Copyright (C) 2012-2017 Edgewall Software