7/21/2015

將網頁或PDF檔案裡的中文字片段抽出後,利用Calibre合成正確的段落

在Calibre 中開啟文字檔案。
將文字檔案內容 import 後轉成 epub格式檔案。

Edit book in Calibre.
1. 在 Edit book 中啟動 "Marked text" option。
2. 使用 mouse,配合 Ctrl+Shift+M 將欲處理的文字標示起來。
3. 使用 Calibre 中的 regular expression (Regex) option,作 search & replace。

Regular expression routine
Find: (.*)([^。|^!|^”|^:]{1})\n\n  
Replace: \1\2

說明
若某一文字片段在
之前不為「。」或不為「!」,或不為「”」或不為「:」則去掉後面的\n等字元。\n: 換行的識別字元 (i.e., newline)

Click on "Find" box.
Click on "Replace all" box. All the patterns in the marked text which match the regular expression described above will be processed.
Repeat the above  procedure several cycles, until the search routine does not find more contents to be replaced.