mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Merge pull request 'Fixes for HTML stuff' (#153) from freamon/pyfedi:10 into main
Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/153
This commit is contained in:
commit
5e20658474
1 changed files with 4 additions and 2 deletions
|
@ -221,8 +221,8 @@ def markdown_to_html(markdown_text) -> str:
|
|||
if markdown_text:
|
||||
raw_html = markdown2.markdown(markdown_text, safe_mode=True, extras={'middle-word-em': False, 'tables': True, 'fenced-code-blocks': True, 'strike': True})
|
||||
# replace lemmy spoiler tokens with appropriate html tags instead. (until possibly added as extra to markdown2)
|
||||
re_spoiler = re.compile(r':{3} spoiler\s+?(\S.+?\n)(.+?)\n:{3}', re.S)
|
||||
raw_html = re_spoiler.sub(r'<details><summary>\1</summary>\2</details>', raw_html)
|
||||
re_spoiler = re.compile(r':{3} spoiler\s+?(\S.+?)(?:\n|</p>)(.+?)(?:\n|<p>):{3}', re.S)
|
||||
raw_html = re_spoiler.sub(r'<details><summary>\1</summary><p>\2</p></details>', raw_html)
|
||||
return allowlist_html(raw_html)
|
||||
else:
|
||||
return ''
|
||||
|
@ -245,6 +245,8 @@ def microblog_content_to_title(html: str) -> str:
|
|||
continue
|
||||
else:
|
||||
tag = tag.extract()
|
||||
else:
|
||||
tag = tag.extract()
|
||||
|
||||
if title_found:
|
||||
result = soup.text
|
||||
|
|
Loading…
Reference in a new issue