Compare commits

...

4 Commits

Author SHA1 Message Date
sejo 084b06d2aa styling tests 2021-12-14 20:54:41 -06:00
sejo 7c6198b51b sanitize html symbols 2021-12-14 20:54:32 -06:00
sejo 8bf1a82941 added <main> 2021-12-14 20:27:23 -06:00
sejo 9aba0013cc replaced printf with print 2021-12-14 20:24:52 -06:00
3 changed files with 26 additions and 9 deletions

20
g2e.awk
View File

@ -113,10 +113,10 @@ ARGIND==2 && FNR==1{
# finalize metadata files
content = content " </manifest>\n\n" spinetoc " </spine>\n\n</package>"
printf content > epubodir "content.opf"
print content > epubodir "content.opf"
toc = toc " </navMap>\n</ncx>"
printf toc > epubodir "toc.ncx"
print toc > epubodir "toc.ncx"
}
@ -126,8 +126,8 @@ ARGIND==2 && FNR==1{
function finishfile(){
# finish writing the previous content file
out = out " </body>\n</html>"
printf out > nameout
out = out "\t</main>\n </body>\n</html>"
print out > nameout
}
function append(line){
out = out "\t" line "\n"
@ -153,6 +153,12 @@ FNR==1 {
next
}
function sanitize(){
gsub("&","\\&amp;")
gsub("<","\\&lt;")
gsub(">","\\&gt;")
}
# --------------------------
# gemtext to html conversion
# --------------------------
@ -165,7 +171,9 @@ FNR==1 {
next
}
is_pre{
sanitize()
append($0)
next
}
@ -179,6 +187,7 @@ is_pre{
# lists
sub(/^\*[[:space:]]*/,""){
if(!is_list){ append("<ul>"); is_list = 1 }
sanitize()
append("<li>" $0 "</li>")
next
}
@ -186,12 +195,14 @@ sub(/^\*[[:space:]]*/,""){
# headers
match($0,/^#{1,3}+/){
sub(/^#{1,3}[[:space:]]+/,"",$0)
sanitize()
append( "<h" RLENGTH ">" $0 "</h" RLENGTH ">")
next
}
# blockquote
sub(/^>[[:space:]]*/,""){
sanitize()
append("<blockquote>" $0 "</blockquote>")
next
}
@ -222,6 +233,7 @@ sub(/^\+[[:space:]]*/,""){
# paragraphs
{
sanitize()
append("<p>" $0 "</p>")
}

View File

@ -7,4 +7,7 @@
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body>
<header>
<h1>{title}</h1>
</header>
<main>

View File

@ -1,17 +1,19 @@
body{
body {
padding: 1em;
font-family:sans-serif;
font-family: sans-serif;
}
pre{
background-color: #fee;
padding:1em;
background-color: #eee;
overflow-x: auto;
padding: 0.5em;
}
blockquote{
font-style: italic;
}
header h1{
font-size:3em;
}
th,td{
border-style:ridge;
padding:5px;