Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org convert to Markdown has wrong URL link format #124

Open
heptaspirit opened this issue Jul 27, 2022 · 1 comment
Open

Org convert to Markdown has wrong URL link format #124

heptaspirit opened this issue Jul 27, 2022 · 1 comment

Comments

@heptaspirit
Copy link

I try to use this tool to convert my logseq org-mode file into MD, all things right, but URL has broken.

This is original org-mode file

* Blog.Agency
:PROPERTIES:
:collapsed: true
:END:
** [[https://sylvainmenguy.com/en/][Sylvain Menguy - blog]]
** Minecraft 国家建筑师
:PROPERTIES:
:collapsed: true
:END:
*** [[https://space.bilibili.com/24323][国家建筑师Cthuwork]]
** [[https://gamediscover.co/][GameDiscoverCo]]

And after converting, there is MD file

- Blog.Agency  
:PROPERTIES:
:collapsed: true
:END:
	- [[https://sylvainmenguy.com/en/][Sylvain Menguy - blog]]  
	- Minecraft 国家建筑师  
:PROPERTIES:
	  :collapsed: true
:END:
		- [[https://space.bilibili.com/24323][国家建筑师Cthuwork]]  
	- [[https://gamediscover.co/][GameDiscoverCo]]  

The URLs in the converted MD file are still org-mode format, so they can’t be rendered correctly.

@Lionade
Copy link

Lionade commented Jan 7, 2024

For anyone having the same issue and seeking a quit solution:
I created a small zsh script to find all occurrences (in a directory and all its subdirectories) of the org-mode link syntax and converted it to the markdown one. Just change the SEARCH_DIR var to your Logseq directory.

#!/bin/zsh

export LC_ALL=C

# Directory to search for files
SEARCH_DIR="*LOGSEQ DIR*"

# Find and convert all files in the directory and subdirectories
find "$SEARCH_DIR" -type f -exec zsh -c '
    # Function to convert string format
    convert_string_format() {
        local file=$1

        # Use sed to replace the string format
        sed -i "" -E "s/\[\[([^][]*)\]\[([^][]*)\]\]/[\2](\1)/g" "$file"
    }

    # Call the function with the current file
    convert_string_format "$1"
' zsh-shell {} \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants