#!/usr/bin/env python import argparse, json, sys, markdown, shutil, json, re, pathlib, shutil input_dir = None output_dir = None style = None codebase = pathlib.Path(__file__).parent.absolute() def translate_index_header(txt, dirname): href = None sections = txt.count('- - -'); if sections == 0: # not following the normal template -> direct html txt = txt.replace('data/', dirname + '/'); #<--- replace reference to data/ return txt elif sections == 1: [text, link] = txt.split('- - -'); elif sections == 2: [text, link, href] = txt.split('- - -'); text_md = markdown.markdown(text); link_md = markdown.markdown(link); # revise this - perhaps with a better link_md = link_md.replace('data/', dirname + '/'); table = codebase / "templates/" with table.open(encoding="utf-8") as fp: out = fp.read() out = out.replace('[[text_md]]', text_md); out = out.replace('[[link_md]]', link_md); if href: href = href.replace('data/', dirname + '/'); out = "" + out + ""; return out def escape_date(dirname): return re.sub('^20\d{2}?.', '', dirname) def emit_img(file: pathlib.Path, data_dir: pathlib.Path): ## this is where LOD can be applied return f'' def emit_video_mp4(file: pathlib.Path, data_dir: pathlib.Path): return f'