After import of EPUB file internal hyperlinks are broken

If I import an EPUB into Pressbooks, the internal hyperlinks that are correctly working in the EPUB file are not correct in Pressbooks anymore.

This is because filenames and paths (chapter, front-matter, back-matter) are not the same in Pressbooks as in the EPUB.

What is the proper way to import EPUB, such that the internal hyperlinks are still working in Pressbooks?

Issue could be related to the following statement in the file /inc/modules/import/epub/class-epub201.php

/**
	 * Change hrefs
	 *
	 * @param \DOMDocument $doc
	 * @param string $type front-matter, part, chapter, back-matter, ...
	 * @param string $href original filename, with (relative) path
	 *
	 * @return \DOMDocument
	 */
	protected function kneadHref( \DOMDocument $doc, $type, $href ) {

		// TODO: Fix self-referencing URLs

		return $doc;
	}

Maybe the code that is missing in the TO-DO above can be derived from the function fixInternalLinks of the cloning routine pressbooks/class-cloner.php at dev · pressbooks/pressbooks · GitHub

I am not a coder. If anybody is willing to fix this, I am willing to pay for the job.

My collegue fixed the issue and placed a pullrequest:

1 Like