<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://entorb.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Ebook_Edit</id>
	<title>Ebook Edit - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://entorb.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Ebook_Edit"/>
	<link rel="alternate" type="text/html" href="https://entorb.net//wiki/index.php?title=Ebook_Edit&amp;action=history"/>
	<updated>2026-05-06T10:25:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://entorb.net//wiki/index.php?title=Ebook_Edit&amp;diff=5014&amp;oldid=prev</id>
		<title>Torben at 05:19, 12 November 2024</title>
		<link rel="alternate" type="text/html" href="https://entorb.net//wiki/index.php?title=Ebook_Edit&amp;diff=5014&amp;oldid=prev"/>
		<updated>2024-11-12T05:19:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;I have some old and poorly formatted ebooks. This is how I fixed them.&lt;br /&gt;
&lt;br /&gt;
Used the application https://calibre-ebook.com that comes with a gui and a cli tool.&lt;br /&gt;
&lt;br /&gt;
I found Calibre to give better results than pandoc.&lt;br /&gt;
&lt;br /&gt;
==Automated fixes using Calibre GUI==&lt;br /&gt;
open ebook in Calibre editor, e.g. via shortcut &amp;quot;T&amp;quot; in Calibre GUI&lt;br /&gt;
* Tools&lt;br /&gt;
** Check book &amp;quot;F7&amp;quot;&lt;br /&gt;
** Remove unused CSS rules&lt;br /&gt;
** Upgrade book internals (convert epub V2 to V3)&lt;br /&gt;
&lt;br /&gt;
==Edit via Python etc.==&lt;br /&gt;
Export source code&lt;br /&gt;
* open ebook in Calibre editor, e.g. via shortcut &amp;quot;T&amp;quot; in Calibre GUI&lt;br /&gt;
* merge all text files into one (by marking them and right-click&lt;br /&gt;
* copy &amp;amp; paste the resulting complete html code into any editor and save the file (this is better than exporting the epub as html, as this leads to modifications)&lt;br /&gt;
perform some magic via Python, Perl, etc. (do not modify the exported file, use it read-only)&lt;br /&gt;
* first do some manual fixes, like&lt;br /&gt;
 cont = cont.replace(&amp;quot;Some Typo&amp;quot;, &amp;quot;Fixed Typo&amp;quot;, 1)&lt;br /&gt;
* use asserts to ensure problem stays fixed, even after further change of script code&lt;br /&gt;
 was = r&amp;quot;&amp;lt; p &amp;gt;Part: ([^&amp;lt;+])&amp;lt; /p &amp;gt;&amp;quot;&lt;br /&gt;
 cnt_parts = len(re.findall(was, cont))&lt;br /&gt;
 cont = re.sub(was, r&amp;quot;\n\n&amp;lt; h1 &amp;gt;Part: \1&amp;lt; /h1 &amp;gt;\n\n&amp;quot;, cont)&lt;br /&gt;
 assert cnt_parts == 4, f&amp;quot;{cnt_parts} == 4&amp;quot;&lt;br /&gt;
 assert &amp;quot;&amp;lt; p &amp;gt;Part&amp;quot; not in cont&lt;br /&gt;
* ensure to have title and author in head block as well as inline CSS&lt;br /&gt;
 &amp;lt;title&amp;gt;The Title of the Book&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;meta name=&amp;quot;author&amp;quot; content=&amp;quot;Lastname, Firstname&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 div.myclass{font-style: italic;}&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
* use h1,h2,h3 for ToC structuring&lt;br /&gt;
* re-create the epub ebook via Calibre CLI tool:&lt;br /&gt;
 ebook-convert &amp;quot;$FILE.html&amp;quot; &amp;quot;$FILE.epub&amp;quot; --level1-toc &amp;quot;//h:h1&amp;quot; --level2-toc &amp;quot;//h:h2&amp;quot; --level3-toc &amp;quot;//h:h3&amp;quot; --language de-DE --no-default-epub-cover --cover &amp;quot;cover.jpg&amp;quot;&lt;br /&gt;
* for completeness, here the alternative pandoc command:&lt;br /&gt;
 pandoc --standalone --from=html &amp;quot;$FILE.html&amp;quot; -o &amp;quot;$FILE.epub&amp;quot; --epub-cover-image=&amp;quot;cover.jpg&amp;quot; --epub-chapter-level=2 -c &amp;quot;pandoc.css&amp;quot;&lt;/div&gt;</summary>
		<author><name>Torben</name></author>
	</entry>
</feed>