generate valid epub
This commit is contained in:
parent
b9b847b4b4
commit
2a68f9970a
22
g2e.awk
22
g2e.awk
|
@ -34,11 +34,11 @@ BEGIN{
|
|||
}
|
||||
|
||||
# setup epub
|
||||
system( "mkdir -p " epubodir "OEBPS" )
|
||||
system( "mkdir -p " epubodir "META-INF" )
|
||||
system( "mkdir -p " epubodir indexdirname )
|
||||
system( "cp -u " tdir "container.xml " epubodir "META-INF/" )
|
||||
system( "cp -u " tdir "mimetype " epubodir )
|
||||
system( "cp -u " tdir "style.css " epubodir "OEBPS" )
|
||||
system( "cp -u " tdir "style.css " epubodir )
|
||||
|
||||
# read templates
|
||||
templatefiles = "find " tdir " -type f -not -name '.*'"
|
||||
|
@ -81,10 +81,10 @@ ARGIND==1 && /^=>/{
|
|||
ch["id"] = id
|
||||
ch["name"] = name
|
||||
ch["num"]++
|
||||
|
||||
content = content " <item id=\"" id "\" href=\"" id ".xhtml\" media-type=\"application/xhtml+xml\"/>\n"
|
||||
ch["dir"] = indexdirname
|
||||
content = content " <item id=\"" id "\" href=\"" indexdirname id ".xhtml\" media-type=\"application/xhtml+xml\"/>\n"
|
||||
spinetoc = spinetoc " <itemref idref=\"" id "\" />\n"
|
||||
toc = toc write_template( "toc-navmap.ncx", ch )
|
||||
toc = toc write_template( "toc-navpoint.ncx", ch )
|
||||
next
|
||||
}
|
||||
|
||||
|
@ -95,20 +95,20 @@ ARGIND==1{ # skip other lines of the index
|
|||
# when finished reading the index:
|
||||
ARGIND==2 && FNR==1{
|
||||
content = content " </manifest>\n\n" spinetoc " </spine>\n\n</package>"
|
||||
printf content > epubodir "OEBPS/content.opf"
|
||||
printf content > epubodir "content.opf"
|
||||
|
||||
toc = toc "</ncx>"
|
||||
printf toc > epubodir "OEBPS/toc.ncx"
|
||||
toc = toc " </navMap>\n</ncx>"
|
||||
printf toc > epubodir "toc.ncx"
|
||||
}
|
||||
|
||||
# content files
|
||||
function finishfile(){
|
||||
# finish writing the previous content file
|
||||
out = out "\t</main>\n </body>\n</html>"
|
||||
out = out " </body>\n</html>"
|
||||
printf out > nameout
|
||||
}
|
||||
function append(line){
|
||||
out = out "\t\t" line "\n"
|
||||
out = out "\t" line "\n"
|
||||
}
|
||||
|
||||
# setup the writing for this content file
|
||||
|
@ -120,7 +120,7 @@ FNR==1 {
|
|||
filenamestart = RSTART
|
||||
match(id,/.gmi$/)
|
||||
name = substr(id,filenamestart,RSTART-filenamestart)
|
||||
nameout = epubodir "OEBPS/" name ".xhtml"
|
||||
nameout = epubodir indexdirname name ".xhtml"
|
||||
|
||||
sub(/#{1,3}\s+/,"", $0)
|
||||
m["title"] = $0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?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"/>
|
||||
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
|
||||
</rootfiles>
|
||||
</container>
|
||||
</container>
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
|
||||
<title>{title}<title>
|
||||
<link rel="stylesheet" href="style.css" type="text/css" />
|
||||
<title>{title}</title>
|
||||
<link rel="stylesheet" href="../style.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>{title}</h1>
|
||||
<header>
|
||||
<main>
|
||||
<h1>{title}</h1>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
body{
|
||||
padding: 1em;
|
||||
font-family:sans-serif;
|
||||
}
|
||||
pre{
|
||||
background-color: #fee;
|
||||
padding:1em;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
blockquote{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
th,td{
|
||||
border-style:ridge;
|
||||
padding:5px;
|
||||
}
|
|
@ -22,3 +22,4 @@ including those that conform to the relaxed constraints of OPS 2.0 -->
|
|||
<text>{author}</text>
|
||||
</docAuthor>
|
||||
|
||||
<navMap>
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<navMap>
|
||||
<navPoint class="chapter" id="{id}" playOrder="{num}">
|
||||
<navLabel><text>{name}</text></navLabel>
|
||||
<content src="{id}.xhtml"/>
|
||||
</navPoint>
|
||||
</navMap>
|
|
@ -0,0 +1,4 @@
|
|||
<navPoint id="id-{id}" playOrder="{num}">
|
||||
<navLabel><text>{name}</text></navLabel>
|
||||
<content src="{dir}{id}.xhtml"/>
|
||||
</navPoint>
|
Loading…
Reference in New Issue