Allow a and span tags in posts

Fixes #39
This commit is contained in:
Mouse Reeve 2020-03-12 17:23:55 -07:00
parent a8ea3c08c9
commit ec45f8d565

View file

@ -6,7 +6,7 @@ class InputHtmlParser(HTMLParser):
def __init__(self): def __init__(self):
HTMLParser.__init__(self) HTMLParser.__init__(self)
self.whitelist = ['p', 'b', 'i', 'pre'] self.whitelist = ['p', 'b', 'i', 'pre', 'a', 'span']
self.tag_stack = [] self.tag_stack = []
self.output = [] self.output = []
# if the html appears invalid, we just won't allow any at all # if the html appears invalid, we just won't allow any at all
@ -16,7 +16,7 @@ class InputHtmlParser(HTMLParser):
def handle_starttag(self, tag, attrs): def handle_starttag(self, tag, attrs):
''' check if the tag is valid ''' ''' check if the tag is valid '''
if self.allow_html and tag in self.whitelist: if self.allow_html and tag in self.whitelist:
self.output.append(('tag', '<%s>' % tag)) self.output.append(('tag', self.get_starttag_text()))
self.tag_stack.append(tag) self.tag_stack.append(tag)
else: else:
self.output.append(('data', ' ')) self.output.append(('data', ' '))