Commit dc691a29 authored by Bartek Górny's avatar Bartek Górny

strip html tags from found text displayed in listbox

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9072 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d027369d
import string
import string, re
redundant_chars='"\'.:;,-' # chars we need to strip from a word before we see if it matches
tr=string.maketrans(redundant_chars,' '*len(redundant_chars))
......@@ -59,7 +59,16 @@ def generateParts(context,text,sw,tags,trail,maxlines):
def cutFound(context,txt,sw,tags,trail,maxlines):
# initialize class
FoundWord.tags=tags
# strip html tags (in case it is a web page - we show result without formatting)
r=re.compile('<script>.*?</script>',re.DOTALL|re.IGNORECASE)
r=re.compile('<head>.*?</head>',re.DOTALL|re.IGNORECASE)
txt=re.sub(r,'',txt)
r=re.compile('<([^>]+)>',re.DOTALL|re.IGNORECASE)
txt=re.sub(r,'',txt)
r=re.compile('\s+')
txt=re.sub(r,' ',txt)
text = ' '.join(txt.split('\n')).split(' ') # very rough tokenization
return [p for p in generateParts(context,text,sw,tags,trail,maxlines)]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment