OneNoteの箇条書きをScrapboxの記法に変換する
インデントの構造
(tabがn個)(固有の文字)(半角スペース)
code:python
def onenote2scb(s):
lines = Util.str2lines(s)
L1 = "\t• "
L2 = "\t\t○ "
L3 = "\t\t\t§ "
L4 = "\t\t\t\t□ "
L5 = "\t\t\t\t\t® "
L6 = "\t\t\t\t\t\t◊ "
L7 = "\t\t\t\t\t\t\t} "
L8 = "\t\t\t\t\t\t\t\t– "
newlines = []
for line in lines:
newline = line
newline = newline.replace(L1, " "*1)
newline = newline.replace(L2, " "*2)
newline = newline.replace(L3, " "*3)
newline = newline.replace(L4, " "*4)
newline = newline.replace(L5, " "*5)
newline = newline.replace(L6, " "*6)
newline = newline.replace(L7, " "*7)
newline = newline.replace(L8, " "*8)
newlines.append(newline)
newstr = Util.lines2str(newlines)
return newstr
これはもうちょい簡単に書けるな
code:python
newline = line
for i,L in enumerate(Ls):
space_count = i+1
newline = newline.replace(L, " "*space_count)
みたいな