Convert Joplin Markdown notes without math to mobi for reading on Kindle
When there are no mathematical symbols or equations in Joplin notes, we had better use the mobi format to read them on Kindle. At present, the conversion is performed in three steps.
- Export Joplin notes to
Markdown + Front Matter
. -
Convert the exported Markdown files to the epub format.
#!/bin/bash # @file: md2epub.sh export https_proxy=http://192.168.0.100:1080; export http_proxy=http://192.168.0.100:1080; pandoc -f markdown -t epub --epub-metadata="$2" -o "${1%md}epub" "$1"
In the above Bash script, before executing
pandoc
, https and http proxy servers are specified, which are used for downloading images from abroad. The pandoc option--epub-metadata
is used to specify the language information in the converted document. According to here, the language should be in the BCP7 format, such asen-US
,en-GB
,zh-CN
,zh-TW
, etc. From Wikipedia, a list of common language tags can be found. The metadata file is in XML format as below.<dc:language>en-GB</dc:language>
The above language configuration is very important. Otherwise, when the finally obtained mobi file is opened in Kindle, assume it is an English article, no English fonts can be configured but only Chinese fonts.
-
Convert the epub files to mobi format by using the
ebook-convert
command provided by Calibre.ebook-convert "${1%md}epub" "${1%md}mobi" --no-inline-toc
Combine step 2 and step 3 into a single script:
#!/bin/bash
# @file: md2mobi.sh
md2epub.sh "$1" "$2"
ebook-convert "${1%md}epub" "${1%md}mobi" --no-inline-toc
To convert all the Markdown files in the current folder, execute this command:
ls *.md | xargs -I "{}" md2mobi.sh "{}" ../en-gb-metadata.xml