txt2mobi is a simple tool for converting txt file to Mobi format for kindle. It's Based on golang package mobi.
Note: All testing were done on Kindle App for windows and Kindle Paperwhite (10th Gen)
PS: Any html element in text file would make effect.
go get -u github.com/zhnxin/txt2mobi
-
Prepare the cover,thumbnail and txt file
-
Create a config file witch you can refer to example.toml
-
Run the command:
[linux]$./txt2mobi -f example.toml [- o output_file_name.mobi] [-p]
#for Windows
[windows]$ txt2mobi.exe -f example.toml [- o output_file_name.mobi] [-p]require:
-config: config file
or
require:
-f: input file-title: book title-author: book author-cover: book cover and thumbnail-chapter: chater title regexp pattern
options:
-subchapter: subchapter title regexp patterncompress: is to compress the resultencoding:: use gb18030 as default
other options:
-o: output file name-p: is to use '<p></p>' to pack every paragrahes.-escape: to disable html escape
title="Example"
author="zhengxin"
file="example.txt"
cover="cover_example.jpg"
chapter="^Chapter\\.\\d+.*$"
subchapter='^Chapter\\.\\d+\-\\d+ .*$'
compress=false
//default cover size
//cover_width=860
//cover_hight=1200Note:
title: If the output_filename is not given, thetitlewould be used as default.chapter: A regexp pattern to determin the chapter line title.compress: If it's true, the output would be compressed witch make the file smaller but take mush time to finish.encoding: Options. Useutf-8as default. Also supportgb18030andgbk.
This tool is ready simple but modifis all need for me. Email me if you really desire it.
The prefixed blank would be ignore because of html decoding.