diff --git a/markdown_fix_freeplane/markdown_utils.py b/markdown_fix_freeplane/markdown_utils.py index 8054f0c..de5d449 100644 --- a/markdown_fix_freeplane/markdown_utils.py +++ b/markdown_fix_freeplane/markdown_utils.py @@ -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