Commits

hc committed 50d31f1

Strip newlines from title tag

Comments (0)

Files changed (1)

plugin_h_search/__init__.py

 
 Author  : Hans Christian von Stockhausen <hc at vst.io>
 Date    : 2011-01-13
-Home    : http://bitbucket.org/hc/plugin_h_search
+Source  : http://bitbucket.org/hc/plugin_h_search
+Demo    : http://vsttemp.appspot.com (Google Appengine)
 License : MIT (see LICENSE)
 
 This module implements a simple search engine for web2py-powered sites. It is 
                 t.extract()
         for comment in soup.findAll(text=lambda t: isinstance(t, Comment)):
             comment.extract()       
-        # extract page title
+        # extract page title and strip newlines if any
         title = soup.html.head.title.string or 'Untitled'
+        title = re.sub('\n', ' ', title).strip()
         # strip html and remove newlines
         contents = ' '.join(soup.findAll(text=True))
         contents = re.sub('\n', ' ', contents)