logseq-to-org-roam/links

15 lines
506 B
Text
Raw Permalink Normal View History

2024-04-20 09:49:30 +00:00
#!/bin/bash
# Convert Logseq link syntax into standard Markdown link syntax.
# Changing the path of links to the assets folder - if you don't know why you'd
# need this, then comment it out
sed -i 's/\[\.\.\/assets/\[assets/g' "$1"
# Convert '[[pagename]]' links
sed -E -i 's/\[\[(.*)\]\]/[\1](\1)/g' "$1"
# Convert '#pagename' links
sed -E -i '/```/,/```/ !s/ #([^ ]+)/ [\1](\1)/g' "$1"
# ('!' inverts range - everywhere except in code blocks. We need this because
# code comments may begin with '#')