Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def no_inner_link(item: str) -> bool:
"""Check that capture link does not contain inner links."""
return re.match(r"\[.*?\]\(\S*?\)", item) is None

def abs_url(self, doc_path: "DocPath") -> str:
def abs_url(self, doc_path: "DocPath", is_md: bool) -> str:
"""Returns an absolute URL based on quoted relative URL from obsidian-export."""

if self.url is None or self.url == "":
Expand All @@ -116,8 +116,12 @@ def abs_url(self, doc_path: "DocPath") -> str:
.resolve()
.relative_to(docs_dir)
)
if(is_md):
new_rel_path = Path(str(new_rel_path) + ".md")
new_rel_path = quote(str(slugify_path(new_rel_path, False)))

if(is_md):
return f"/docs/{new_rel_path[:-3]}"
return f"/docs/{new_rel_path}"
except Exception:
print(f"Invalid link found: {doc_path.old_rel_path}")
Expand All @@ -131,7 +135,7 @@ def parse(cls, line: str, doc_path: "DocPath") -> Tuple[str, List[str]]:
linked: List[str] = []

for link in cls.get_links(line):
abs_url = link.abs_url(doc_path)
abs_url = link.abs_url(doc_path, link.is_md)
parsed = parsed.replace(
link.combined, f"[{link.title}]({abs_url}{link.header})"
)
Expand Down