kopia lustrzana https://github.com/tsileo/little-boxes
commit
4166b0477f
|
@ -1,10 +1,11 @@
|
|||
import re
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import Tuple
|
||||
|
||||
from markdown import markdown
|
||||
|
||||
import regex as re
|
||||
|
||||
from .activitypub import get_backend
|
||||
from .webfinger import get_actor_url
|
||||
|
||||
|
@ -24,7 +25,11 @@ MENTION_REGEX = re.compile(r"@[\d\w_.+-]+@[\d\w-]+\.[\d\w\-.]+")
|
|||
def hashtagify(content: str) -> Tuple[str, List[Dict[str, str]]]:
|
||||
base_url = get_backend().base_url()
|
||||
tags = []
|
||||
for hashtag in re.findall(HASHTAG_REGEX, content):
|
||||
hashtags = re.findall(HASHTAG_REGEX, content)
|
||||
hashtags = list(set(hashtags)) # unique tags
|
||||
hashtags.sort()
|
||||
hashtags.reverse() # replace longest tag first
|
||||
for hashtag in hashtags:
|
||||
tag = hashtag[1:]
|
||||
link = f'<a href="{base_url}/tags/{tag}" class="mention hashtag" rel="tag">#<span>{tag}</span></a>'
|
||||
tags.append(dict(href=f"{base_url}/tags/{tag}", name=hashtag, type="Hashtag"))
|
||||
|
|
|
@ -5,3 +5,4 @@ markdown
|
|||
pyld
|
||||
pycryptodome
|
||||
html2text
|
||||
regex
|
||||
|
|
4
setup.py
4
setup.py
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from distutils.core import setup
|
||||
import io
|
||||
import os
|
||||
from distutils.core import setup
|
||||
|
||||
from setuptools import find_packages
|
||||
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
|
@ -29,6 +30,7 @@ REQUIRED = [
|
|||
"pycryptodome",
|
||||
"html2text",
|
||||
"mdx_linkify",
|
||||
"regex",
|
||||
]
|
||||
|
||||
DEPENDENCY_LINKS = []
|
||||
|
|
Ładowanie…
Reference in New Issue