Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created January 26, 2022 21:59
Show Gist options
  • Save Utopiah/119f5c96fae048609a2091f7f3d81f53 to your computer and use it in GitHub Desktop.
Save Utopiah/119f5c96fae048609a2091f7f3d81f53 to your computer and use it in GitHub Desktop.
#!/bin/bash
# could be stored on ~/bin/generateEpubTemplate on the reMarkable
mkdir -p META-INF OEBPS
echo '<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>' > ./META-INF/container.xml
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title of the document</title>
</head>
<body>
Content of the cover page
</body>
</html>' > ./OEBPS/cover.xhtml
echo '<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" xmlns:opf="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="BookID">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>The title</dc:title>
</metadata>
<manifest>
<item id="content.xhtml" href="content.xhtml" media-type="application/xhtml+xml"/>
<item id="toc.xhtml" href="toc.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine toc="ncx">
<itemref idref="content.xhtml"/>
</spine>
<guide>
<reference title="Table of content" type="toc" href="toc.xhtml"/>
</guide>
</package>' > ./OEBPS/content.opf
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title of the document</title>
</head>
<body>
Content of the page
</body>
</html>' > ./OEBPS/content.xhtml
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title of the document</title>
</head>
<body>
Content of the TOC page
</body>
</html>' > ./OEBPS/toc.xhtml
echo application/epub+zip > ./mimetype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment