From 0ee843179f245a560ecae7b3ed485a107b5fea90 Mon Sep 17 00:00:00 2001 From: Damian Flynn Date: Fri, 2 Dec 2022 23:30:03 +0000 Subject: [PATCH] bug: initial release issues image links bundle paths duplicate title and H1 --- .vscode/launch.json | 2 +- main.py | 2 +- obsidian_parser/obsidianparser.py | 9 ++++++--- setup.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 18b5b86..609b419 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -31,7 +31,7 @@ "--hugo-content-dir", "/Users/damianflynn/Sites/damianflynn/content", "--obsidian-vault-dir", - "/Users/damianflynn/Sites/obsidian" + "/Users/damianflynn/vault/Cranium" "--export-dir", "share" ] diff --git a/main.py b/main.py index 1981e9b..60ede95 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ import argparse import os -__version__ = "0.2.0" +__version__ = "0.3.0" parser = argparse.ArgumentParser() diff --git a/obsidian_parser/obsidianparser.py b/obsidian_parser/obsidianparser.py index acc0112..2681abe 100644 --- a/obsidian_parser/obsidianparser.py +++ b/obsidian_parser/obsidianparser.py @@ -207,9 +207,10 @@ def retrieve_bundle_assets(self, hugo_page: str) -> None: link["link"] = "opps-missing-image.png" # Update the link in the Hugo Page. - hugo_link = f'![{link["text"]}]({link["link"]})' + hugo_link = f'![{link["text"]}]({link["link"]})' # HTML Link + hugo_link = f'![[{link["link"]}|{link["text"]}]]' # Wiki Link wiki_link = link["source"] - #note_content = note_content.replace(wiki_link, hugo_link) + note_content = note_content.replace(wiki_link, hugo_link) # Write the Updated Page content. with open(os.path.join(hugo_page), "w", encoding = "utf-8") as f: @@ -288,11 +289,13 @@ def replace_wiki_links(self, text: str) -> str: def check_frontmatter(self, hugo_page: str): post = frontmatter.loads(hugo_page) + post_body = post.content #first_heading = re.search(r"^# (.*)", post.content, re.MULTILINE) title_heading = re.search(r"^# (.*)", post.content, re.MULTILINE) if title_heading: title_heading = title_heading.group(1) print('First Match = {}'.format(title_heading)) + post_body = post_body.replace(f'# {title_heading}\n', '') else: print('Not Found') @@ -318,7 +321,7 @@ def check_frontmatter(self, hugo_page: str): newpost += f"toc: {post['toc']}\n" if 'toc' in post.keys() else f"toc: false \n" newpost += f"comments: {post['comments']}\n" if 'comments' in post.keys() else f"comments: false \n" newpost += f"---\n\n" - newpost += post.content + newpost += post_body return newpost def reformat_article(self, hugo_page: str) -> None: diff --git a/setup.py b/setup.py index 8f84a35..68f869c 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ # This call to setup() does all the work setup( name="obsidian-parser", - version="0.2.0", + version="0.3.0", description="Demo library", long_description=long_description, long_description_content_type="text/markdown",