!/usr/bin/awk -f

BEGIN{

# Printing header!

if(ENVIRON["baseURL"] == ""){

    baseURL="/"

} else {

    baseURL = ENVIRON["baseURL"]

}

if(ENVIRON["webLang"] == ""){

    webLang="en"

} else {

    webLang = ENVIRON["webLang"]

}

printf("<!DOCTYPE html>\n\

<meta charset=\"utf-8\" />\n\

<title>^_^</title>\n\

<link rel=\"stylesheet\" type=\"text/css\" href=\"%s/style.css\">\n\

# Link types

lImg = "^pic:"

# Control variables

pre = 0

list = 0

}

First we change all < and > into < and >. This will cause conflicts

with links (=>) and quotes (>) but it will be easier to check only then than

keep converting at each rule.

{

gsub(/&/, "\\&amp;")

gsub(/</, "\\&lt;")

gsub(/>/, "\\&gt;")

}

/^```/&&(pre == 0){

# We must close the list!

if(list == 1){

    list = 0

    print "</ul>"

}

emptyLine = 0

pre = 1

printf "<pre><code>"

next

}

/^```/&&(pre == 1){

pre = 0

print "</code></pre>"

next

}

(pre == 1){

print $0

next

}

We insert empty lines only if there is more than one. We don't need to add

extra spacing between paragraphs.

/^[ \t]*$/&&(emptyLine == 0){

emptyLine = 1

next

}

/^[ \t]*$/&&(emptyLine == 1){

print "<br/>"

next

}

If there is something that is not an empty line

(emptyLine == 1){

emptyLine = 0

}

/* /{

if(list == 0){

    list = 1

    print "<ul>"

}

sub(/\* [ \t]*/, "")

print "<li>"$0"</li>"

next

}

If the list has ended

(list == 1){

list = 0

print "</ul>"

}

/^---/{

print "<hr/>"

next

}

/^###/{

sub(/^#[#]*[ \t]*/, "")

print "<h3>"$0"</h3>"

next

}

/^##/{

sub(/^#[#]*[ \t]*/, "")

print "<h2>"$0"</h2>"

next

}

/^#/{

sub(/^#[#]*[ \t]*/, "")

print "<h1>"$0"</h1>"

next

}

/^>/{

sub(/^&gt;[ \t]*/, "")

print "<blockquote><p>&gt; "$0"</p></blockquote>"

next

}

/^=>/{

sub(/^=&gt;[ \t]*/, "")

url=$0

sub(/[ \t].*$/, "", url)

text=$0

sub(/^[^ \t]*/, "", text)

sub(/[ \t]*$/, "", text)

sub(/^[ \t]*/, "", text)

# If it's a local gemini file, link to the html:

if((url !~ /^[a-zA-Z]*:\/\//) && ((url ~ /\.gmi$/) || (url ~ /\.gemini$/))){

    sub(/\.gmi$/, ".html", url)

    sub(/\.gemini$/, ".html", url)

}

if(text == ""){

    text = url

}

if(text ~ lImg){

    sub(lImg,"",text)

    sub(/^[ \t]*/,"",text)

    print "<p class=\"img\"><a href=\""url"\"><img src=\""url"\"/>"text"</a></p>"

} else {

    print "<p><a href=\""url"\">⇒ "text"</a></p>"

}

next

}

{

print "<p>"$0"</p>"

}

END{

# Closes open list

if(list == 1){

    print "</ul>"

}

print "</body>\n</html>"

}

Proxy Information
Original URL
gemini://texto-plano.xyz/draco/gmi2html
Status Code
Success (20)
Meta
application/octet-stream
Capsule Response Time
903.717323 milliseconds
Gemini-to-HTML Time
1.724023 milliseconds

This content has been proxied by September (3851b).