Closed simpleowen closed 5 years ago
mobi 是 亚马逊 kindle 的专有阅读格式.
亚马逊提供了一个 工具 支持从其他格式 (HTML, XHTML and EPUB) 来创建 mobi 文档, 但是该工具目前支持的格式并不包括 md.
Highlights of KindleGen functionality
Support for all KF8 functionality
Generates a single file supporting both KF8 and Mobi format
Support for multiple source formats including HTML, XHTML and EPUB
System Requirements
Windows XP, Vista or 7
Intel Mac OSX 10.5 or later
Linux 2.6 i386
所以要想使用 KindleGen 来将 md 转换成 mobi 格式, 必须先将 md 转换成 HTML, XHTML and EPUB 中的一种中间格式, 再将中间格式转换 mobi.
html 是非常常见的网页格式, 从 md to html 开始.
md to html 的工具非常多, 有在线的, 离线的, GUI 的, CLI 的.
比如, 在线服务 Dillinger 能将 md 转换为 html.
将 md 文档内容导入, 或拷贝到左边 markdown 编辑器中, 在右上角有 export as 可选 html 格式导出. 如下图所示:
➜ kindlegen
*************************************************************
Amazon kindlegen(MAC OSX) V2.9 build 1028-0897292
A command line e-book compiler
Copyright Amazon.com and its Affiliates 2014
*************************************************************
Usage : kindlegen [filename.opf/.htm/.html/.epub/.zip or directory] [-c0 or -c1 or c2] [-verbose] [-western] [-o <file name>]
Note:
zip formats are supported for XMDF and FB2 sources
directory formats are supported for XMDF sources
Options:
-c0: no compression
-c1: standard DOC compression
-c2: Kindle huffdic compression
-o <file name>: Specifies the output file name. Output file will be created in the same directory as that of input file. <file name> should not contain directory path.
-verbose: provides more information during ebook conversion
-western: force build of Windows-1252 book
-releasenotes: display release notes
-gif: images are converted to GIF format (no JPEG in the book)
-locale <locale option> : To display messages in selected language
en: English
de: German
fr: French
it: Italian
es: Spanish
zh: Chinese
ja: Japanese
pt: Portuguese
ru: Russian
nl: Dutch
使用 kindlegen 命令后确实能将 html 转换成 mobi, 但用 kindle 打开后, 中文显示乱码.
html 文件字符集为 utf-8.
xmlns="http://www.w3.org/1999/xhtml" lang="zh_hans" xml:lang="zh_hans"
等<head>
<meta charset="utf-8">
<title>提问的智慧.md</title>
<style type="text/css">
body{
font-family: arial, sans-serif;
}
</style>
</head>
依然乱码.
参考连接:
将 md 转换成 epub, 使用 Pandoc 工具.
pandoc -o howtoask.epub howtoask.md
定位到相应目录下, 执行
kindlegen howtoask.epub
➜ kindlegen howtoask.epub
*************************************************************
Amazon kindlegen(MAC OSX) V2.9 build 1028-0897292
A command line e-book compiler
Copyright Amazon.com and its Affiliates 2014
*************************************************************
➜ echo $?
2
没能成功转换 epub -> mobi
暂时先关闭此 issue, 后续跟踪.
背景
近日想复习一下 提问的智慧.
在网上找到一个 mobi 版本, 但是 kindle 阅读效果不理想. 于是想着尝试将仓库中的 md 文档转换成 mobi 后发送到 kindle 阅读, 看看效果是否可行.