Arguments

This commit is contained in:
2026-07-16 09:59:47 +02:00
parent 69e5c62382
commit 080e51526f
7 changed files with 182 additions and 49 deletions
+1 -37
View File
@@ -1,39 +1,3 @@
#!/bin/sh
input=$(cat -)
input="${input#odin run src/}"
style="<style>$(cat styles.css)</style>"
doctype='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
meta='<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
start="$doctype<html><head><title>TypoML Preview</title>$meta$style</head><body>"
script='
<script>
(function () {
var defs = {};
var spans = document.querySelectorAll("[data-tlm-def]");
for (var i = 0; i < spans.length; i++) {
var el = spans[i];
defs[el.dataset.tlmDef] = el.dataset.tlmValue;
}
var tlm = new Proxy({}, {
get: function (_, name) {
return defs[name];
},
set: function (_, name, value) {
defs[name] = value;
var refs = document.querySelectorAll("[data-tlm-var=\"" + name + "\"]");
for (var i = 0; i < refs.length; i++) {
refs[i].textContent = value;
}
return true;
},
ownKeys: function () {
return Object.keys(defs);
}
});
window.tlm = tlm;
})();
</script>'
end="$script</body></html>"
output="$start$input$end"
echo "$output" > preview.html
cat - > preview.html
nohup xdg-open preview.html > /dev/null 2>&1 &