Skip to content

a simple tool for txt to .mobi format converter

Notifications You must be signed in to change notification settings

isgasho/txt2mobi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TXT2MOBI

README_ZH_cn.md

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.

Build

Get the following packges.

  • github.com/766b/mobi
  • github.com/BurntSushi/toml
  • golang.org/x/text/encoding/simplifiedchinese

support default cover:

  • github.com/golang/freetype/truetype
  • github.com/nfnt/resize
  • golang.org/x/image/font
  • github.com/fogleman/gg

Install go-bindata

go get -u github.com/jteeuwen/go-bindata/...

Run the build cmd:

go-bindata -o assets/asset.go -pkg=assets assets/...
go build

Usage

  1. Prepare the cover,thumbnail and txt file

  2. Create a config file witch you can refer to example.toml

  3. 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]

termimal parameter

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 pattern
  • compress: is to compress the result
  • encoding:: 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

config file

title="Example"
author="zhengxin"
file="example.txt"
cover="cover_example.jpg"
thumbnail="cover_example.jpg"
chapter="^Chapter\\.\\d+.*$"
subchapter='^Chapter\\.\\d+\-\\d+ .*$'
compress=false

Note:

  • title: If the output_filename is not given, the title would 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. Use utf-8 as default. Also support gb18030 and gbk.

Need GUI?

This tool is ready simple but modifis all need for me. Email me if you really desire it.

About BLANK

The prefixed blank would be ignore because of html decoding.

About

a simple tool for txt to .mobi format converter

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages