試著使用 Windows 的視窗編輯器來撰寫 Gitbook
目前測試了 Miu 跟 MarkdownPad 這兩個編輯器
不過前者 Miu 因為 Liveview 並不支援 HTML 語法,所以被我拋棄了
等他有支援再回去用看看
PS. Mac 上大家推的都是 Mou
而用 Windows 寫 Gitbook 就不像在 Linux 上有 gitbook init 可以產生相對映的 md 檔案
就改之前寫的 parse.py 來產生吧 (這邊使用的 python 版本是 3.0)
會根據SUMMARY的 標題 進行創建
創建的 md 也會先寫入 標題n–
這樣也不用打開後還不知道這是哪一頁了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# -*- coding: utf-8 -*- import re import os for line in open("SUMMARY.md", encoding='utf-8'): try: src1 = re.search('[(.+?)]((.+?))', line) print(src1.group(1)) src = src1.group(2) except: print(line) else: cnt = src.count('/') if cnt == 3: tempstr = re.search('(.+?)/(.+?)/(.+?)/(.*)', src) path = tempstr.group(1) + "\" + tempstr.group(2) + "\" + tempstr.group(3) file = tempstr.group(1) + "\" + tempstr.group(2) + "\" + tempstr.group(3) + "/" + tempstr.group(4) if not os.path.isdir(path): print("create folder: " + path) os.mkdir(path) if not os.path.isfile(file): print("create file: " + file) newfile = open(file, "w") newfile.write(src1.group(1)) newfile.write("n--") newfile.close() print(tempstr.group(1) + ".." + tempstr.group(2) + ".." + tempstr.group(3) + ".." + tempstr.group(4)) elif cnt == 2: tempstr = re.search('(.+?)/(.+?)/(.*)', src) path = tempstr.group(1) + "\" + tempstr.group(2) file = tempstr.group(1) + "\" + tempstr.group(2) + "\" + tempstr.group(3) if not os.path.isdir(path): print("create folder: " + path) print(path) os.mkdir(path) if not os.path.isfile(file): print("create file: " + file) newfile = open(file, "w") newfile.write(src1.group(1)) newfile.write("n--") newfile.close() print(tempstr.group(1) + ".." + tempstr.group(2) + ".." + tempstr.group(3)) elif cnt == 1: tempstr = re.search('(.+?)/(.*)', src) path = tempstr.group(1) file = tempstr.group(1) + "\" + tempstr.group(2) if not os.path.isdir(path): print("create folder: " + path) os.mkdir(path) if not os.path.isfile(file): print("create file: " + file) newfile = open(file, "w") newfile.write(src1.group(1)) newfile.write("n--") newfile.close() print(tempstr.group(1) + ".." + tempstr.group(2)) |