Skip to content

Commit

Permalink
Keep mention attributes when filtering annotation markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Feb 19, 2025
1 parent 6db614b commit 8a5098f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions h/services/mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

from sqlalchemy import delete
from sqlalchemy.orm import Session
from util.markdown_render import MENTION_ATTRIBUTE, MENTION_USERID

from h.models import Annotation, Mention
from h.services.html import parse_html_links
from h.services.user import UserService

MENTION_ATTRIBUTE = "data-hyp-mention"
MENTION_USERID = "data-userid"
MENTION_LIMIT = 5

logger = logging.getLogger(__name__)
Expand Down
5 changes: 4 additions & 1 deletion h/util/markdown_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from markdown import Markdown

LINK_REL = "nofollow noopener"
MENTION_ATTRIBUTE = "data-hyp-mention"
MENTION_USERID = "data-userid"

MARKDOWN_TAGS = [
"a",
Expand Down Expand Up @@ -52,7 +54,8 @@ def render(text):


def _filter_link_attributes(_tag, name, value):
if name in ["href", "title"]:
# Keep attributes used in mention tags
if name in ["href", "title", MENTION_ATTRIBUTE, MENTION_USERID]:
return True

if name == "target" and value == "_blank":
Expand Down

0 comments on commit 8a5098f

Please sign in to comment.