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
11 changes: 7 additions & 4 deletions N2Omodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def embedded_link_convert(line):

# folder style links
#regexPath = compile("^\[(.+)\]\(([^\(]*)(?:\.md|\.csv)\)$") # Overlap incase multiple links in same line
#regexRelativePathImage = compile("(?:\.png|\.jpg|\.gif|\.bmp|\.jpeg|\.svg)")
regexRelativePathImage = compile("(?:\.png|\.jpg|\.gif|\.bmp|\.jpeg|\.svg)")

regexPath = compile("!\[(.*?)\]\((.*?)\)")
regex20 = compile("%20")
Expand All @@ -197,7 +197,7 @@ def embedded_link_convert(line):
# modify paths into local links. just remove UID and convert spaces
Title = pathMatch.group(1)
relativePath = pathMatch.group(2)
#is_image = regexRelativePathImage.search(relativePath)
is_image = regexRelativePathImage.search(relativePath)

regexSpecialUtf8 = compile("%([A-F0-9][A-F0-9])%([A-F0-9][A-F0-9])%([A-F0-9][A-F0-9])")
regexutf8 = compile("%([A-F0-9][A-F0-9])%([A-F0-9][A-F0-9])")
Expand Down Expand Up @@ -236,7 +236,10 @@ def embedded_link_convert(line):
else:
relativePath = regexutf8.sub(unicode_str, relativePath, 1)

line, num_matchs = regexPath.subn("[["+relativePath+"]]", line)
if is_image:
line, num_matchs = regexPath.subn("![["+relativePath+"]]", line)
else:
line, num_matchs = regexPath.subn("[["+relativePath+"]]", line)

if num_matchs > 1:
print(f"Warning: {line} replaced {num_matchs} matchs!!")
Expand Down Expand Up @@ -347,4 +350,4 @@ def N2Omd(mdFile):
return newLines, [in_link_cnt, em_link_cnt, bl_link_cnt,tags_cnt]