Skip to content

Commit

Permalink
feat: support slashes in wikilinks (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff authored Apr 9, 2024
2 parents f7212d8 + 7d207ff commit 8fc90ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion memium/source/document_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions memium/source/test_document_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 8fc90ac

Please sign in to comment.