mirror of https://github.com/scrapy/scrapy.git
rolled back public ent_re to private and added a function has_entities instead
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40282
This commit is contained in:
parent
ad00d5e632
commit
f8f2f3a542
|
|
@ -5,7 +5,7 @@ Functions for dealing with markup text
|
|||
import re
|
||||
import htmlentitydefs
|
||||
|
||||
ent_re = re.compile(r'&(#?)([^&;]+);')
|
||||
_ent_re = re.compile(r'&(#?)([^&;]+);')
|
||||
_tag_re = re.compile(r'<[a-zA-Z\/!].*?>', re.DOTALL)
|
||||
|
||||
def remove_entities(text, keep=(), remove_illegal=True):
|
||||
|
|
@ -45,8 +45,10 @@ def remove_entities(text, keep=(), remove_illegal=True):
|
|||
else:
|
||||
return u'&%s;' % m.group(2)
|
||||
|
||||
return ent_re.sub(convert_entity, text.decode('utf-8'))
|
||||
return _ent_re.sub(convert_entity, text.decode('utf-8'))
|
||||
|
||||
def has_entities(text):
|
||||
return bool(_ent_re.search(text))
|
||||
|
||||
def replace_tags(text, token=''):
|
||||
"""Replace all markup tags found in the given text by the given token. By
|
||||
|
|
|
|||
Loading…
Reference in New Issue