Originally Posted by fish99
TBH I had no idea epub files contained code, I thought it was just formatted text, like a .doc file or something, i.e. a very simple format. I guess I can try reformatting the files in calibre since I'm assuming calibre would product better/cleaner files.
An ePub is a set of files in a zipped containing file. There are a few files that describe the reset. These contain things like the metadata, TOC, list of the files and order they are used in. These files are XML. The text of the book is in one or more files. These use HTML for the layout of the text.
Running a conversion in calibre can make better code or worse. If the code in the source is bad, calibre tends to produce cleaner code. Or at least it produces code that is more consistent and easier for me to modify if I want to. For good source, the output is generally good, but it can merge some styles and do a couple of things I don't like.