💾 Archived View for gemtext.space › code.gmi captured on 2023-01-29 at 02:33:02. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
┬┌┬┐┌─┐┬ ┬┌┬┐┬┌┬┐┬ ┬┌─┐ ┬ ┌─┐┬ ┬┌─┐ ┌─┐┌─┐┌─╮┌┬┐ ┌┬┐┌─┐┬ ┬┌┬┐ │ ││├┤ │╲│ │ │ │ └┬┘┌─┘ │ │ ││╲││┌┐ ├┤ │ │├( │││ │ ├┤ ╳ │ ┴ ┴┘└─┘┴ ┴ ┴ ┴ ┴ ┴ └── └─┘└─┘┴ ┴└─┘ ┴ └─┘┴ ┴┴ ┴ ┴ └─┘┴ ┴ ┴
This site is a working demonstration of taking a standard gemini capsule and auto generating and distributing derived MD, Web, LaTeX, PDF, ePub, etc.
If you can improve on my ugly Python and the HTML template please share your ideas, and although the Eisvogel works magically I am sure something simple and elegant can devised for this specific task.
I am interested in futhering and promoting gemtext encoding /gemini as an integral part for the complete heirachy of longtext publishing.
This site is processed thru Gemtext to Markdown, Markdown to Html, Markdown to LaTeX, Latex to PDF, PDF to print. If that all works ok finalstep of Htm to eBooks should be trivial.
Gemtext encoding is identical to COMMONMARK standard markdown except for the URL encoding, so the following converts it to commonmark.
[Python3] modif = '' with open(fi, 'r') as i_file: while True: line = i_file.readline() if not line: break if "=> " in line: line = re.sub('=> ', '<a href="', line) line = re.sub('.gmi +', '.html">', line) line = re.sub(' +', '">', line) line = re.sub('\n', '</a>', line) line = re.sub('gemini://', 'https://', line) modif = f'{modif} {line}\n\n' else: modif = f'{modif} {line}' mdfile.write(modif) mdfile.close()
With the execption that the html encoded url is ignored by pandoc in the following
[Python3] md = re.sub('.gmi', '.md', fi) texdir = re.sub('gemini', 'gemini-tex', tex) title = re.sub('.gmi', '', file) os.system( f'pandoc --standalone --from=commonmark --metadata title="{title}" ' f'--template tmplt.html {md} -o {htm}' )
With tmplt.html being something like the following
[html] <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="date" content='$date-meta