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