$book->addChapter("Chapter 3: Vivamus bibendum massa again", "Chapter003.html", $chapter3);
// Autosplit a chapter:
$log->logLine("Add Chapter 4");
$book->setSplitSize(15000);
// For this test, we split at approx 15k. Default is 250000 had we left it alone.
$book->addChapter("Chapter 4: Vivamus bibendum massa split", "Chapter004.html", $chapter4, true);
$book->setSplitSize(250000);
$book->subLevel();
$book->addChapter("Chapter 4B: test inlined chapter", "Chapter004.html#sub01");
$book->backLevel();
// More advanced use of the splitter:
// Still using Chapter 4, but as you can see, "Chapter 4" also contains a header for Chapter 5.
require_once 'EPubChapterSplitter.php';
$log->logLine("include EPubChapterSplitter.php");
$splitter = new EPubChapterSplitter();
$splitter->setSplitSize(15000);
// For this test, we split at approx 15k. Default is 250000 had we left it alone.
$log->logLine("new EPubChapterSplitter()");
/* Using the # as regexp delimiter here, it makes writing the regexp easier.
 *  in this case we could have just searched for "Chapter ", or if we were using regexp '#^<h1>Chapter #i',
 *  using regular text (no regexp delimiters) will look for the text after the first tag. Meaning had we used
 *  "Chapter ", any paragraph or header starting with "Chapter " would have matched. The regexp equivalent of
 *  "Chapter " is '#^<.+?>Chapter #'
 * Essentially, the search strnig is looking for lines starting with...
 */
$log->logLine("Add Chapter 5");
$html2 = $splitter->splitChapter($chapter5, true, "Chapter ");
/* '#^<.+?>Chapter \d*#i'); */
$log->logLine("Split chapter 5");
$idx = 0;
while (list($k, $v) = each($html2)) {