The Magic and the Sauce
December 21, 2025

I wrote a cosmic horror novel The Fifth Anomaly: A Threshold Chronicle with a companion metalcore album, QR codes linking chapters to tracks, an in-world website, and an AI chatbot based on one of the characters. Here’s how.

Medium - Markdown

First, I’m a software engineer before a writer. This is my first attempt writing a book, so I stuck to a medium I’m most comfortable with. All of the chapters in the book are written as markdown in the following tree format:

├── assets
│   ├── cover.jpg           # Book Cover (for EPUB)
│   ├── epub.css            # Custom Styling for the EPUB
├── book.toml
│   ├── en
│   │   ├── back            # All back matter included heree
│   │   │   ├── author.md
│   │   │   ├── media.md
│   │   │   └── teaser.md
│   │   ├── chapter_10.md
│   │   ├── chapter_11.md
│   │   ├── chapter_12.md
│   │   ├── chapter_13.md
│   │   ├── chapter_14.md
│   │   ├── chapter_15.md
│   │   ├── chapter_16.md
│   │   ├── chapter_17.md
│   │   ├── chapter_18.md
│   │   ├── chapter_19.md
│   │   ├── chapter_1.md
│   │   ├── chapter_20.md
│   │   ├── chapter_2.md
│   │   ├── chapter_3.md
│   │   ├── chapter_4.md
│   │   ├── chapter_5.md
│   │   ├── chapter_6.md
│   │   ├── chapter_7.md
│   │   ├── chapter_8.md
│   │   ├── chapter_9.md
│   │   ├── copyright.md     # Front Matter
│   │   ├── foreword.md      # Front Matter
│   │   ├── metadata.yaml    # EPUB Metadata containing ISBN details etc
│   │   └── summary.md       # Front Matter
│   ├── notes.md

This format is structured for src/${LANG}/... for a number of reasons:

  1. This is native for MDBook. While writing it in markdown, I can read it in real time in the web UI for MDBook.
  2. I am only publishing the English language version, but it’s also written in Brazilian Portuguese so my wife could read it as I wrote it.

I hosted the content in gitlab (but you could use github. I just prefer the gitlab runners) as a private repo. Then whenever I created a tag, gitlab would automatically create an EPUB , DOCX and HTML for the tag itself.

The Gitlab Automation Profile

The snippet is rather large so you can find it here as a public snippet on gitlab. A few things to discuss:

  1. Latex and several of its derivatives are included here so that you could render a PDF although I was unable to
    1. This may be uncommon for most of you, but I’m using a lot of non unicode characters, and was down into the weeds of building byte-maps to font mapping to produce it before it just stopped being worth it
  2. The artifacts themselves are set to expire after a year in my repo. The goal is to collect them and put them somewhere else, not let gitlab be your permanent location for artifacts
  3. Pandoc does the real heavy lifting here and my options are not generic. You may need to tweak them as you try them out

The Album

I’m a big fan of transmedia creators like Claudio Sanchez (Coheed and Cambria), so I wanted there to be a companion album for it as it tends to hit emotional beats a lot harder than prose does. Downside, I have three boys, a fulltime job, and I haven’t touched anything but drums in years.

What really worked for me was going to suno.com with a production notebook of styles, lyrics and then using Suno Studio to pull stems out and master / remaster as needed in Adobe Audition. The Final album 10,000 [Ye|Fe]ars is available on spotify and each song represents a separate portion of the album (mostly chapter 6 forward as the plot picks up).

Delivery Mechanism

The question then becomes “If you’re looking at print and digital, how to deliver the album / songs”. For digital (most e-readers support it) you can include a link by itself. For print, however, it’s a different problem.

I used qrencode to do this, but to save you a lot of time you have to specify an 8bit png or you’ll run into “why isn’t this showing up in the book” when it renders

qrencode -o output.png -t PNG -8 "https://your-link-here.com"

If you don’t specify an 8bit you get 1 bit, and there’s so little to show in the HTML that most readers just abandon it as empty space in the EPUB. After re-generating at 8 bit, everything shows up fine.

Summary

I created a bunch of QR codes and dumped them in src/assets with the cover. Then just used markdown to include them at the end of a chapter that pertains to a song on the album. I chose after rather than before to avoid any spoilers and not burden people with shuffling mediums around if they’re in a flow.

Concerns and Confusion

So, my book is in markdown making it easy to make changes with sed and the like. I can view the line by line changes over time in the git history, and automate the EPUB generation. I thought I was doing well until editing

Editing

When I hired an editor, there was a discussion about “how do you want me to add my commentary” and I plainly said “Oh you can just create a merge request on gitlab”. This led to a lot of

confusion

He just wanted a .docx file, so I updated the pipeline to produce a docx and gave it to him. I then went on my merry way changing more crap which was half of my problem.

Editing took longer than I anticipated and the book was wildly different by the time his commentary had come in. I had to write a python script to extract the comments from the docx and then correlate them to a chapter / known line to make sense of it.

From there, I created issues in gitlab to track them all (I don’t sound like a writer at all :-/) and just knocked them out one by one as I had time. I learned a lot about what not to do next time, so hey. That’s a plus…right?

Publishing

I have an EPUB. It has been edited. I am ready

Those were words I actually thought, but there’s a LOT to consider:

ISBNS

If you’re going to own the ISBNs and their barcodes (which I recommend) you have to purchase them and assign them via bowker (For the USA). That meant actually encoding it into the EPUB.

---
title: "<INSERT TITLE>"
subtitle: "<INSERT SUBTITLE"
author: "<INSERT NAME>"
lang: en-US   # Only if it's in english obviously
identifier:
    - scheme: ISBN
	  text: <INSERT YOUR ISBN HERE>
rights: "© 2025 <INSERT NAME>. All rights reserved."
publisher: "My Magical Publishing Company" # The name of your imprint from Bowker
date: "2025-12-31" #This...doesn't really matter that much
description: |
	Insert your multi-line description here!
	Many lines will work!

If you’ve generated the EPUB with the metadata you can view these details in the information pane for the book in most ereaders like foliate

Formatting

So here’s where we get into a situation you may not run into like me. My book has:

  • Significant styling applied (for discord / digital conversations)
  • Significant use of CKJ (China / Korea / Japan) fonts for Kaomojis

This means fonts really matter. What I ended up having to do was move to embedded fonts for the EPUB to allow noto as the primary monospace font and noto-emoji for other things. This is part of the EPUB specification

Verify to the target medium as best as you can

This is super important. If you’re planning on just direct selling the EPUB. I’d say load it up in the reader of your choice and be satisfied, but if you’re going somewhere else, you need to confirm whatever you’re generating works in that medium

AWS KDP for example, will take an EPUB but it operates on mobi formats beneath the hood and does a lot of translation. It took a lot of back and forth to resolve styling issues with fencing, even realizing my kaomoji icons weren’t showing up when they were fine in Calibre or Foliate.

It was just unexpected and crippling to be like “Yeah I’m finally ready to publish!” and then realizing “oh…I’m uh..not”.

I used the kindle previewer to iterate pretty quickly though. It was a day of time more or less after realizing this was messed up to get it resolved to thanks to that.