mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-09-27 14:00:21 +00:00
26 lines
522 B
Python
26 lines
522 B
Python
"""Clean user-provided text"""
|
|
import bleach
|
|
|
|
|
|
def clean(input_text: str) -> str:
|
|
"""Run through "bleach" """
|
|
return bleach.clean(
|
|
input_text,
|
|
tags=[
|
|
"p",
|
|
"blockquote",
|
|
"br",
|
|
"b",
|
|
"i",
|
|
"strong",
|
|
"em",
|
|
"pre",
|
|
"a",
|
|
"span",
|
|
"ul",
|
|
"ol",
|
|
"li",
|
|
],
|
|
attributes=["href", "rel", "src", "alt", "data-mention"],
|
|
strip=True,
|
|
)
|