💾 Archived View for d.moonfire.us › blog › 2018 › 08 › 25 › mfgames-writing-formats captured on 2021-11-30 at 20:18:30. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2022-01-08)

-=-=-=-=-=-=-

Additional Formats for MfGames Writing

Up a Level

Previous

Next

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.

1: /tags/mfgames-writing/

Series

I appear to be writing a short series of post about the tools I use for publication and writing.

2: /blog/2018/08/13/publishing-processes/

3: /blog/2018/08/21/mfgames-writing-reasons/

4: /blog/2018/08/22/mfgames-writing-init/

5: /blog/2018/08/23/mfgames-writing-content/

6: /blog/2018/08/24/mfgames-writing-docker-and-ci/

7: /blog/2018/08/26/mfgames-writing-themes/

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

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.

10: https://weasyprint.org/

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:

Programming

Writing

Tags:

Markdown

MfGames Writing

Footer

Below are various useful links within this site and to related sites (not all have been converted over to Gemini).

Contact

Biography

Bibliography

Fiction

Fedran

Coding

Categories

Tags

Privacy

Colophon

https://d.moonfire.us/blog/2018/08/25/mfgames-writing-formats/