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

Fixed "ewpage" appearing in PDF output #56

Open khaos-codi opened 3 months ago

khaos-codi commented 3 months ago

The "ewpage" Issue: Found and Fixed

Problem Identified

After investigating the build process, I identified the source of the "ewpage" text appearing at the end of specific pages in the PDF output. The issue was in the combine-markdown.sh script.

When combining markdown files, the script was using the following line to add page breaks after each section:

echo -e "\n\n\\\\newpage\n\n" >> "$OUTPUT_PATH"

The problem was with the backslash escaping. In bash, when using echo -e, escaping requires doubling the backslashes. However, something in the processing chain was causing this to be improperly handled, resulting in literal "ewpage" text (instead of a proper LaTeX \newpage command) being inserted into the output file.

Solution Applied

I modified the script to use simpler escaping:

echo -e "\n\n\\newpage\n\n" >> "$OUTPUT_PATH"

With this change, the proper LaTeX command \newpage is written to the file, which Pandoc correctly interprets as a page break. This eliminates the "ewpage" text that was appearing in the PDF.

Technical Details

Escaping in bash can be tricky, especially when commands are processed through multiple layers (like echo, file redirection, and then Pandoc). The original escaping (\\\\newpage) was likely getting processed as follows:

  1. First level of bash processing: \\\\\\
  2. echo -e processing: \\\
  3. But something was consuming one more backslash, leaving just ewpage

By simplifying to \\newpage, we ensure that after echo -e processing, we get the correct \newpage in the output file.

Verification

This fix has been committed to the main branch. The next build of the book should have proper page breaks without any "ewpage" text appearing in the final PDF.

If you want to verify the fix without doing a full build, you can check the content of the combined markdown file after running combine-markdown.sh to make sure it contains \newpage instead of "ewpage".

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