1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 08:22:56 +01:00

Stop xenforo from over-stripping styles

This commit is contained in:
David Lynch 2025-08-04 13:31:57 -05:00
parent b3489d5016
commit a71ac62f8b

View file

@ -288,11 +288,13 @@ class XenForo(Site):
# TODO: more robust CSS parsing? This is very whitespace dependent, if nothing else. # TODO: more robust CSS parsing? This is very whitespace dependent, if nothing else.
if "font-family: 'Courier New'" in tag['style']: if "font-family: 'Courier New'" in tag['style']:
tag.wrap(self._new_tag('code')) tag.wrap(self._new_tag('code'))
tag['style'] = tag['style'].replace("", '')
tag['style'] = re.sub(r"font-family: 'Courier New';?", '', tag['style'])
if "text-decoration: strikethrough" in tag['style']: if "text-decoration: strikethrough" in tag['style']:
tag.wrap(self._new_tag('strike')) tag.wrap(self._new_tag('strike'))
tag['style'] = re.sub(r'text-decoration: strikethrough;?', '', tag['style'])
if "margin-left" in tag['style']: if "margin-left" in tag['style']:
continue continue
del tag['style']
for tag in post.select('.quoteExpand, .bbCodeBlock-expandLink, .bbCodeBlock-shrinkLink'): for tag in post.select('.quoteExpand, .bbCodeBlock-expandLink, .bbCodeBlock-shrinkLink'):
tag.decompose() tag.decompose()
for tag in post.find_all('noscript'): for tag in post.find_all('noscript'):