@ -11,6 +11,8 @@ BEGIN{
epubodir = "out/"
metadatafile = gpubdir "metadata.txt"
"date -u +%FT%TZ" | getline meta [ "date" ]
# read metadata file fields
while ( getline < metadatafile ) {
key = $ 1 ; sub ( ":" , "" , key )
@ -90,7 +92,9 @@ ARGIND==1 && /^=>/{
ch [ "name" ] = name
ch [ "num" ] ++
ch [ "dir" ] = indexdirname
content = content " <item id=\"" id "\" href=\"" indexdirname id ".xhtml\" media-type=\"application/xhtml+xml\"/>\n"
properties = ""
if ( id ~ /^toc/ ) properties = "properties=\"nav\""
content = content " <item id=\"" id "\" href=\"" indexdirname id ".xhtml\" media-type=\"application/xhtml+xml\" " properties "/>\n"
spinetoc = spinetoc " <itemref idref=\"" id "\" />\n"
toc = toc write_template ( "toc-navpoint.ncx" , ch )
next
@ -135,6 +139,7 @@ ARGIND==2 && FNR==1{
function finishfile ( ) {
# finish writing the previous content file
if ( name ~ /^toc$/ ) { append ( "</ol></nav>" ) ; is_list = 0 }
if ( is_list ) { append ( "</ul>" ) ; is_list = 0 }
if ( is_pre ) { append ( "</pre>" ) ; is_pre = 0 }
out = out " </main>\n </body>\n</html>"
@ -218,6 +223,19 @@ sub(/^>[[:space:]]*/,""){
next
}
# toc links
name ~ /^toc$/ && sub ( /^=>[[:space:]]*/ , "" ) {
link = $ 1
text = $ 2
for ( i = 3 ; i <= NF ; i ++ ) text = text " " $ i
if ( ! is_list ) { append ( "<nav epub:type=\"toc\"><ol>" ) ; is_list = 1 }
sub ( /gmi$/ , "xhtml" , link )
append ( "<li><a href=\"" link "\">" text "</a></li>" )
next
}
# links?
sub ( /^=>[[:space:]]*/ , "" ) {
link = $ 1
@ -228,7 +246,7 @@ sub(/^=>[[:space:]]*/,""){
append ( "<p><a href=\"" link "\">" text "</a></p>" )
}
else if ( link ~ /(gif|jpg|png)$/ ) {
append ( "< img src=\"" link "\" alt=\"" text "\" / >")
append ( "< picture>< img src=\"" link "\" alt=\"" text "\" / ></picture >")
}
else {
append ( "<p><a href=\"" link "\">" text "</a></p>" )