Created
March 16, 2024 03:50
-
-
Save RyujiAMANO/d7664a8c7ae0d4c45c33712920ea6b82 to your computer and use it in GitHub Desktop.
Scrapbox to Logseq markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
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
MacでScrapboxのテキストをコピーして
してLogseqにはりつけてます。