iksnae / actual-intelligence

A practical, non-technical guide to using AI tools like ChatGPT in everyday life
MIT License
0 stars 0 forks source link

Complete fix for "ewpage" issue in EPUB output #57

Open khaos-codi opened 3 months ago

khaos-codi commented 3 months ago

Root Cause of the "ewpage" Issue Identified and Fixed

After further investigation, I've identified the true root cause of the "ewpage" issue that was persisting in the EPUB output.

The Core Problem

The issue was due to two conflicting page break styles being used in the same document:

  1. The source markdown files were already using HTML-style page breaks:

    <div style="page-break-after: always;"></div>
  2. The combine-markdown.sh script was adding LaTeX-style page breaks:

    \newpage

While PDF output can handle both styles, EPUB conversion was stumbling on the LaTeX \newpage command, resulting in literal "ewpage" text appearing in the final EPUB.

The Solution

I've updated the combine-markdown.sh script to use consistent page break styles that work across all output formats:

  1. For sections that already have page breaks in their source files, I've removed the duplicate page breaks added by the script.

  2. For sections where we need to add page breaks (like title pages, appendices, glossary), I'm now using the HTML style that's compatible with both PDF and EPUB:

    <div style="page-break-after: always;"></div>

Technical Details

The previous fix I applied (changing \\\\newpage to \\newpage) was addressing a symptom but not the underlying cause. The issue wasn't just with backslash escaping in bash, but with the inconsistent approach to page breaks across different output formats.

By using HTML-style page breaks consistently, which are supported by both PDF and EPUB formats, we avoid the conversion issues that were causing "ewpage" to appear.

Verification

The next build of the book should have proper page breaks in both PDF and EPUB formats, without any "ewpage" text appearing in either output.

This solution is more robust because it:

  1. Uses a consistent approach to page breaks
  2. Works across all output formats (PDF, EPUB, HTML)
  3. Avoids duplicating page breaks that already exist in the source files

Let me know if you encounter any other issues with the build process!