Add data-mention attributes to mention links
This commit is contained in:
parent
3084745522
commit
8e7cd7bde9
|
@ -271,7 +271,7 @@ class HTMLProcessor:
|
||||||
|
|
||||||
inlines_attributes = {
|
inlines_attributes = {
|
||||||
"font": {"color"},
|
"font": {"color"},
|
||||||
"a": {"href", "class"},
|
"a": {"href", "class", "data-mention"},
|
||||||
"code": {"class"},
|
"code": {"class"},
|
||||||
}
|
}
|
||||||
attributes = {**inlines_attributes, **{
|
attributes = {**inlines_attributes, **{
|
||||||
|
@ -451,16 +451,20 @@ class HTMLProcessor:
|
||||||
return el
|
return el
|
||||||
|
|
||||||
if self.link_is_user_id_regex.match(href):
|
if self.link_is_user_id_regex.match(href):
|
||||||
if el.text.lstrip().startswith("@"):
|
if el.text.strip().startswith("@"):
|
||||||
el.attrib["class"] = "mention user-id-mention"
|
el.attrib["class"] = "mention user-id-mention"
|
||||||
else:
|
else:
|
||||||
el.attrib["class"] = "mention username-mention"
|
el.attrib["class"] = "mention username-mention"
|
||||||
|
|
||||||
|
el.attrib["data-mention"] = el.text.strip()
|
||||||
|
|
||||||
elif self.link_is_room_id_regex.match(href):
|
elif self.link_is_room_id_regex.match(href):
|
||||||
el.attrib["class"] = "mention room-id-mention"
|
el.attrib["class"] = "mention room-id-mention"
|
||||||
|
el.attrib["data-mention"] = el.text.strip()
|
||||||
|
|
||||||
elif self.link_is_room_alias_regex.match(href):
|
elif self.link_is_room_alias_regex.match(href):
|
||||||
el.attrib["class"] = "mention room-alias-mention"
|
el.attrib["class"] = "mention room-alias-mention"
|
||||||
|
el.attrib["data-mention"] = el.text.strip()
|
||||||
|
|
||||||
return el
|
return el
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user