To separate an EPUB file to multiple file, I need to find all <h2
and replace them with <hr class="sigil_split_marker" /><h2
. However, each element of a chapter is consisted in its own html file, which means I can only replace once at a time. And when splitting it, it gives the error:
Cannot split since at least one file may not be an HTML file.
Q: How to split the file into multiple files, each consists the opening image, chapter name and its contain?
Below is the structure of the file:
Head
Every page has the same head.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Packing for Mars</title>
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
<link href="../Styles/stylesheet.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }</style>
</head>
Image
<body class="calibre">
<div id="filepos129415" class="calibre1">
<div class="calibre30">
<p class="calibre31"><img alt="image" src="../Images/00006.jpg" class="calibre16"/></p>
<div class="calibre32"></div>
</div>
</div>
</body>
</html>
Chapter name
<body class="calibre">
<h2 class="calibre13" id="calibre_pb_30"><span class="calibre10"><span class="bold"><span><span class="bold">YOU GO FIRST</span></span></span></span></h2>
<div class="calibre32"></div>
<p class="calibre8"><span class="calibre12"><span class="bold"><span><span class="italic">CHAPTER NAME</span></span></span></span></p>
<div class="calibre28"></div>
<div class="calibre1">
</div>
</body>
</html>
Content
<body class="calibre">
<div class="mbppagebreak" id="calibre_pb_31"></div>
<p class="calibre33"> </p>
<p>Loren Ipsum</p>