Blog · EPUB

How to Preserve Chapters and Formatting During EPUB Conversion

Know what each target can hold

Formatting does not disappear by accident; it disappears because the target format has nowhere to put it. Decide on the target before you convert, based on what you must keep.

ElementTXTMarkdownPDF (print)
Chapter boundariesBlank linesHeadings and rulesNew page per chapter
Heading levelsLost (own line only)KeptKept
Bold / italicsLostKeptKept
ListsDashes and numbersKept, nestedKept
TablesPipe-separated rowsPipe-separated rowsKept
ImagesAlt text onlyAlt text or ZIP with filesEmbedded
Fonts and coloursLostLostSystem fonts, colours from CSS kept
Links inside the bookLostLostNot clickable
Right-to-left textCharacters keptCharacters keptLaid out right to left

Why chapters go missing or run together

Why formatting looks different afterwards

A five-minute check before you trust a conversion

  1. Count: the number of chapters in the output should match the book’s table of contents.
  2. Search the output for a phrase from the first and from the last chapter.
  3. Open one chapter with a table or list and compare it with the book in the reader.
  4. If the book has images that matter, check that they are present: in the PDF preview, or in the Markdown ZIP’s images folder.
  5. For right-to-left books, check the first line of a paragraph starts on the right.

Choosing the right route

For reading on paper or sharing a fixed copy, use EPUB to PDF. For notes and publishing, use Markdown. For searching and analysis, use plain text. When a book looks wrong in all of them, the problem is probably in the EPUB, and the repair tool is the next stop.

A worked example: chapters in one file

Many EPUBs made from word-processor documents contain the whole text in one XHTML file with headings marking chapters. The book looks chaptered in a reading app because the app builds navigation from the headings. Convert it to plain text and you get a single long file with the headings as lines of text; convert it to Markdown and the chapter headings become # lines you can split on; convert it to PDF and the chapters flow one after another without new pages, because the page break rule works per document, not per heading.

If you need a page break before each chapter in the PDF, there are two ways. Convert the book to Markdown, split it by chapter and convert the pieces separately, or split the chapters into files in an EPUB editor first. Neither is automatic, because deciding what counts as a chapter is the author’s decision.

Emphasis that is only visual

Good EPUBs mark emphasis with em and strong tags. Others use a CSS class such as .italic or .s1 on a span. Visually they look the same in a reading app, but a converter that looks at structure sees a plain span. After converting to Markdown, search for text that you know was italic. If it is plain, the book used class-based styling and the italics can only be restored by hand or by an editor that understands the book’s CSS.

Keeping things that tables and images carry