mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
4295dff760
3 changed files with 15 additions and 4 deletions
|
@ -1066,6 +1066,9 @@ def process_delete_request(request_json, activitypublog_id, ip_address):
|
|||
|
||||
|
||||
def announce_activity_to_followers(community, creator, activity):
|
||||
# remove context from what will be inner object
|
||||
del activity["@context"]
|
||||
|
||||
announce_activity = {
|
||||
'@context': default_context(),
|
||||
"actor": community.profile_id(),
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
--bs-btn-color: white;
|
||||
}
|
||||
|
||||
.post_body a, .comment_body a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.post_list .post_teaser {
|
||||
border-bottom: solid 1px black;
|
||||
}
|
||||
|
@ -83,4 +87,4 @@ div.navbar {
|
|||
}
|
||||
[data-bs-theme="dark"] .coolfieldset.collapsed legend, [data-bs-theme="dark"] .coolfieldset legend, [data-bs-theme="dark"] .coolfieldset.expanded legend {
|
||||
background-color: black;
|
||||
}
|
||||
}
|
||||
|
|
10
app/utils.py
10
app/utils.py
|
@ -169,7 +169,7 @@ def allowlist_html(html: str) -> str:
|
|||
if html is None or html == '':
|
||||
return ''
|
||||
allowed_tags = ['p', 'strong', 'a', 'ul', 'ol', 'li', 'em', 'blockquote', 'cite', 'br', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre',
|
||||
'code', 'img', 'details', 'summary', 'table', 'tr', 'td', 'th', 'tbody', 'thead']
|
||||
'code', 'img', 'details', 'summary', 'table', 'tr', 'td', 'th', 'tbody', 'thead', 'hr']
|
||||
# Parse the HTML using BeautifulSoup
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
|
||||
|
@ -211,13 +211,17 @@ def allowlist_html(html: str) -> str:
|
|||
if tag.name == 'table':
|
||||
tag.attrs['class'] = 'table'
|
||||
|
||||
return str(soup)
|
||||
# avoid returning empty anchors
|
||||
re_empty_anchor = re.compile(r'<a href="(.*?)" rel="nofollow ugc" target="_blank"><\/a>')
|
||||
return re_empty_anchor.sub(r'<a href="\1" rel="nofollow ugc" target="_blank">\1</a>', str(soup))
|
||||
|
||||
|
||||
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})
|
||||
# todo: in raw_html, replace lemmy spoiler tokens with appropriate html tags instead.
|
||||
# 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)
|
||||
return allowlist_html(raw_html)
|
||||
else:
|
||||
return ''
|
||||
|
|
Loading…
Add table
Reference in a new issue