Skip to content

Instantly share code, notes, and snippets.

@RyujiAMANO
Created March 16, 2024 03:50
Show Gist options
  • Save RyujiAMANO/d7664a8c7ae0d4c45c33712920ea6b82 to your computer and use it in GitHub Desktop.
Save RyujiAMANO/d7664a8c7ae0d4c45c33712920ea6b82 to your computer and use it in GitHub Desktop.
Scrapbox to Logseq markdown
#!/usr/bin/env python3
import sys
import re
def scrapbox_to_markdown():
scrapbox_text = sys.stdin.read()
markdown_text = ""
lines = scrapbox_text.split('\n')
for line in lines:
if line.startswith('\t'):
indent = len(line) - len(line.lstrip('\t'))
line = ' ' * (indent) + '- ' + line.lstrip('\t')
else:
line = '- ' + line
# Replace [text url] to [text](url)
line = re.sub(r'\[([^]]*?) (.*?)\]', r'[\1](\2)', line)
markdown_text += line.replace("[", "[[").replace("]", "]]") + "\n"
return markdown_text
markdown_output = scrapbox_to_markdown()
print(markdown_output)
@RyujiAMANO
Copy link
Author

Scrapboxでデイリーページを運用してみてるので、下記でLogseqのデイリーページに追加もありかな

$ pbpaste | ~/bin/sb2ls.py >> Logseqフォルダ/journals/YYYY_MM_DD.md

これでもいいかな

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment