Additional Formats for MfGames Writing
Not everyone in the world uses EPUB. Yes, I consider it one of the best formats for me because I can change font size or layout, there is still a big need for print books and Amazon is the source of most ebook sales (though I don't care for that either).
To handle that, MfGames Writing[1] provides a pluggable collection of different output formats. This allows you to use only the formats that you way (EPUB2, PDF, HTML) and they can be updated separately.
Series
I appear to be writing a short series of post about the tools I use for publication and writing.
- Semantic Versions and Releases[2]: Why semantic versioning helps with the writing process.
2: /blog/2018/08/13/publishing-processes/
- Evolution of MfGames Writing[3]: A brief history and reasoning behind the tools.
3: /blog/2018/08/21/mfgames-writing-reasons/
- First Steps Using MfGames Writing[4]: Starting a new project with MfGames Writing.
4: /blog/2018/08/22/mfgames-writing-init/
- Adding Content to MfGames Writing[5]: Adding front and back matter to novels.
5: /blog/2018/08/23/mfgames-writing-content/
- Working with MfGames Writing, CI, and Docker[6]: Adding automatic building with commits.
6: /blog/2018/08/24/mfgames-writing-docker-and-ci/
- Additional Formats for MfGames Writing: How to create PDF, MOBI, DOCX, and HTML versions.
- Theming for MfGames Writing[7]: A light introduction on how to customize the output.
7: /blog/2018/08/26/mfgames-writing-themes/
- Integrating Semantic Versioning into MfGames Writing[8]: Tying semantic releases into the process.
8: /blog/2018/08/27/mfgames-writing-releases/
Using Formats
Formats are consumed in the edition section of the `publication.yaml` file.
metadata: title: Test Project author: D. Moonfire language: en theme: "@mfgames-writing/clean" outputDirectory: . outputFilename: test-project-{{edition.version}}.{{edition.editionName}} editions: epub: format: "@mfgames-writing/epub2" pdf: format: "@mfgames-writing/weasyprint" isbn: 978-1-999999 html: format: "@mfgames-writing/html" images: scale: 0.25
The format is the name of the package installed with `npm install`.
EPUB
The easiest format to use is EPUB2.
$ npm install @mfgames-writing/epub2 $ npm run build:html
The setup for the NPM commands can be found yesterday[9].
9: /blog/2018/08/24/mfgames-writing-docker-and-ci/
When this runs, it will generate an EPUB2 file that will be verifiable with `epubcheck`.
HTML
HTML is also pretty easy.
$ npm install @mfgames-writing/html
PDF is the complicated one and why I use a Docker image. I decided to use WeasyPrint[10] for PDF generation because it creates good-quality PDF files and works with HTML, the format themes[11] use.
11: /blog/2018/08/26/mfgames-writing-themes/
$ npm install @mfgames-writing/weasyprint
This assumes that `weasyprint` and `pdftk` are both in the PATH.
MOBI
There isn't a good package for generating MOBI files directly, so the best approach to creating a Amazon MOBI file for uploading is to create a EPUB file and then use `kindlegen` to convert it.
$ npm run build:epub $ kindlegen *.epub
DOCX
Like MOBI, it is hard to write a DOCX in a clean manner. To do that, we create a HTML and then convert it.
$ npm run build:html $ sed 's@@@g' < *.html \ | pandoc -f html -t docx -o test-package-0.0.0.docx
We have the extra `sed` command to remove the hypenation from `@mfgames-writing/hyphen` which makes a cleaner file.
Metadata
Categories:
Tags:
Footer
Below are various useful links within this site and to related sites (not all have been converted over to Gemini).
Source