added some comments
This commit is contained in:
parent
d3245db368
commit
fd1ae2cc3a
24
g2e.awk
24
g2e.awk
|
@ -39,8 +39,6 @@ BEGIN{
|
|||
system( "cp -u " tdir "container.xml " epubodir "META-INF/" )
|
||||
system( "cp -u " tdir "mimetype " epubodir )
|
||||
system( "cp -u " tdir "style.css " epubodir )
|
||||
# copy images
|
||||
# system( "cp -u " gpubdir indexdirname "img/* " epubodir indexdirname "img/" )
|
||||
|
||||
|
||||
# read templates
|
||||
|
@ -54,9 +52,9 @@ BEGIN{
|
|||
RS = "\n"
|
||||
}
|
||||
|
||||
# start writing metadata files
|
||||
content = write_template( "content-header.opf", meta )
|
||||
toc = write_template( "toc-header.ncx", meta )
|
||||
|
||||
spinetoc = " <spine toc=\"ncx\">\n"
|
||||
}
|
||||
|
||||
|
@ -74,7 +72,10 @@ function write_template( templatek, values ){
|
|||
return output
|
||||
}
|
||||
|
||||
# ----------------
|
||||
# index file links
|
||||
# ----------------
|
||||
|
||||
ARGIND==1 && /^=>/{
|
||||
id = $2
|
||||
sub(/.gmi$/,"",id)
|
||||
|
@ -102,12 +103,11 @@ ARGIND==2 && FNR==1{
|
|||
while( "find " gpubdir indexdirname "img/ -type f -regextype awk -iregex \".+(png|jpg|gif)$\"" | getline){
|
||||
path = $0
|
||||
dest = path; sub(gpubdir, "", dest)
|
||||
fortoc = dest
|
||||
system( "cp -u " $0 " " epubodir dest) # copy images
|
||||
mediatype = fortoc~/gif$/ ? "image/gif" : fortoc~/jpg$/ ? "image/jpeg" : "image/png"
|
||||
id = fortoc
|
||||
sub(/^.+\//,"",id)
|
||||
content = content " <item id=\"" id "\" href=\"" fortoc "\" media-type=\"" mediatype "\"/>\n"
|
||||
mediatype = dest~/gif$/ ? "image/gif" : dest~/jpg$/ ? "image/jpeg" : "image/png"
|
||||
id = dest
|
||||
sub(/^.+\//,"",id) # get basename
|
||||
content = content " <item id=\"" id "\" href=\"" dest "\" media-type=\"" mediatype "\"/>\n"
|
||||
}
|
||||
$0 = line
|
||||
|
||||
|
@ -119,7 +119,11 @@ ARGIND==2 && FNR==1{
|
|||
printf toc > epubodir "toc.ncx"
|
||||
}
|
||||
|
||||
|
||||
# -------------
|
||||
# content files
|
||||
# -------------
|
||||
|
||||
function finishfile(){
|
||||
# finish writing the previous content file
|
||||
out = out " </body>\n</html>"
|
||||
|
@ -140,7 +144,7 @@ FNR==1 {
|
|||
name = substr(id,filenamestart,RSTART-filenamestart)
|
||||
nameout = epubodir indexdirname name ".xhtml"
|
||||
|
||||
sub(/#{1,3}\s+/,"", $0)
|
||||
sub(/#{1,3}\s+/,"", $0) # use first line as document title
|
||||
m["title"] = $0
|
||||
out = write_template("header.xhtml",m)
|
||||
is_pre = 0
|
||||
|
@ -149,7 +153,9 @@ FNR==1 {
|
|||
next
|
||||
}
|
||||
|
||||
# --------------------------
|
||||
# gemtext to html conversion
|
||||
# --------------------------
|
||||
|
||||
# pre-formatted
|
||||
/^```/{
|
||||
|
|
Loading…
Reference in New Issue