traitement des urls
This commit is contained in:
parent
23314d8a53
commit
3317bb7de6
1 changed files with 5 additions and 0 deletions
|
@ -40,4 +40,9 @@ def replace_title_with_list(text: str) -> str:
|
|||
if nb_hashtag > 1:
|
||||
text = re.sub(match, ' ' * (nb_hashtag-1)+'-', text, count=1)
|
||||
text = re.sub('\n\n', '\n', text)
|
||||
pattern_url = \
|
||||
r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))"
|
||||
matches_url = re.findall(pattern_url, text, re.MULTILINE)
|
||||
for match in matches_url:
|
||||
text = text.replace(str(match[0]), f'[{str(match[0])}]({str(match[0])})')
|
||||
return text
|
||||
|
|
Loading…
Reference in a new issue