From 7d207ff8964b390881a9169ed236db3541eb58cc Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Tue, 9 Apr 2024 11:16:57 +0000 Subject: [PATCH] feat: support slashes in wikilinks --- memium/source/document_source.py | 2 +- memium/source/test_document_source.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/memium/source/document_source.py b/memium/source/document_source.py index ae47bf32..d9a2a10d 100644 --- a/memium/source/document_source.py +++ b/memium/source/document_source.py @@ -33,7 +33,7 @@ def _replace_wikilinks_with_styling(self, input_str: str) -> str: @staticmethod def _replace_alias_wiki_links(text: str) -> str: - regex_pattern = r"\[\[[\w|\s|\d|\(|\)]+\|[\w|\s|\d]+\]\]" + regex_pattern = r"\[\[[\w|\s|\d|\/\(|\)]+\|[\w|\s|\d|\/]+\]\]" pattern_matches = re.findall(pattern=regex_pattern, string=text, flags=re.DOTALL) for match in pattern_matches: diff --git a/memium/source/test_document_source.py b/memium/source/test_document_source.py index 77da8822..be3d9a1c 100644 --- a/memium/source/test_document_source.py +++ b/memium/source/test_document_source.py @@ -51,3 +51,11 @@ def test_sanitize_to_valid_markdown(self): ) == expected_output ) + + +def test_replace_alias_wiki_links(): + text = "Linking to a valid [[Note/Note2|Note Alias]], and can handle [[Note2|Multiple Aliases]]" + expected_output = "Linking to a valid [[Note Alias]], and can handle [[Multiple Aliases]]" + assert ( + MarkdownDocumentSource(directory=Path())._replace_alias_wiki_links(text) == expected_output # type: ignore + )