kindlegenamazon提供的html转换mobi的软件。

download

grutatxt

其中比较有用的选型是

    -t|--title=TITLE           Document title (if unset,
                               level 1 heading is used)

    --encoding=ENCODING        Character encoding (default: iso-8859-1)

linux convert txt to mobi

First, edit the text file and indent all lists (per grutatxt man page).  With this trick, grutatxt to treats all indents as lists.  This, in turn, prevents grutatxt from omitting the newline (carriage return) at the end of each list item creating a paragraph instead.  We don't want a paragraph for lists.  We want lists, and this trick can be used to prevent any lines of text from getting their newline stripped.  Later, if you don't like the look of indentions or free space prefixing your lists within the final HTML, you can edit the HTML page and simple delete the white space within the lists (between the <pre> tags).

To convert the text file into a new HTML file:
$ grutatxt < MyFile.txt > MyFile.html


To add a Title, edit the resulting HTML file with a text editor and enter a Title within the <Title></Title> HTML tags.  ie:
<Title>A Stone for Danny Fisher</Title>.

To add an Author, add the following entry directly below the first and only <META> HTML tag entry found at the top of the HTML file:

<meta name="Author" content="Harold Robbins">

Use kindlegen to convert the .html to a .mobi file:
$ kindlegen MyFile.html

Copy the file to your Kindle device:
$ copy MyFile.mobi to /media/Kindle/documents/recipes/

其他可能用到的脚本

转换字符编码

enca -x utf8 -L zh < $1 > $TMPFILE
iconv -f gbk -c  filename.txt > newfilename.txt

去空行,并自动空行,以便分段

perl -i -ne 'if(/\S/){s/\r//;print "$_\n"}' $TMPFILE

中文空格开头的段落添加<p>以换行

perl -i -pe 's/^(?= )/\<p\>/'  filename.html

自动脚本


字体修改


引用


字体选用

主字体选择“方正准雅宋”; CJK_Regular.ttf
粗体是“方正特雅宋”;     CJK_Bold.ttf
斜体是“华文中宋斜”       CJK_Italic.ttf
粗斜体是“华文中宋粗斜”   CJK_BoldItalic.ttf

fontconfig

jpan.0=CJK_Regular.ttf
jpan.1=CJK_Bold.ttf
jpan.2=CJK_Italic.ttf
jpan.3=CJK_BoldItalic.ttf
jpan.plain=CJK_Regular.ttf
jpan.bold=CJK_Bold.ttf
jpan.italic=CJK_Italic.ttf
jpan.bolditalic=CJK_BoldItalic.ttf

kore.0=CJK_Regular.ttf
kore.1=CJK_Bold.ttf
kore.2=CJK_Italic.ttf
kore.3=CJK_BoldItalic.ttf
kore.plain=CJK_Regular.ttf
kore.bold=CJK_Bold.ttf
kore.italic=CJK_Italic.ttf
kore.bolditalic=CJK_BoldItalic.ttf

hant.0=CJK_Regular.ttf
hant.1=CJK_Bold.ttf
hant.2=CJK_Italic.ttf
hant.3=CJK_BoldItalic.ttf
hant.plain=CJK_Regular.ttf
hant.bold=CJK_Bold.ttf
hant.italic=CJK_Italic.ttf
hant.bolditalic=CJK_BoldItalic.ttf

hans.0=CJK_Regular.ttf
hans.1=CJK_Bold.ttf
hans.2=CJK_Italic.ttf
hans.3=CJK_BoldItalic.ttf
hans.plain=CJK_Regular.ttf
hans.bold=CJK_Bold.ttf
hans.italic=CJK_Italic.ttf
hans.bolditalic=CJK_BoldItalic.ttf

修改方法

  • 连接kindle,在里面建个空文件,名字是 ENABLE_DIAGS,然后重启你的kindle
  • 从settings菜单中找到你的serial number。用以下代码得到root密码:
#!/usr/bin/env python 
import hashlib 
print("fiona%s"%hashlib.md5("XXXYOURSERIALXXX\n".encode('utf-8')).hexdigest()[7:11])
  • 挂载启动区
mount /dev/mmcblk0p1 /mnt/base-mmc
  • 字体在 /mnt/base-mmc/usr/java/lib/fonts/
  • 内存空间在/mnt/base-us/