{{/* Copyright 2025 Alexander Bass */}} {{/* MIT License */}} {{ $port := 1235 }} {{ $address := "127.0.0.1" }} {{ $tex := .Inner | base64Encode }} {{/* Change this value to invalidate all cached math expressions */}} {{ $cache_bust := 0 }} {{ if not (.Page.Params.math) }} {{ errorf "Math is used despite \"math: true\" not being set in frontmatter on: \n%s" .Position }} {{ end }} {{ $url := printf "http://%s:%d/tex2math/%s/%s?%d" $address $port .Type $tex $cache_bust }} {{ with try (resources.GetRemote $url) }} {{ with .Err }} {{ errorf "Unable to process math with error %s " . }} {{ else with .Value }} {{ $jsonObj := . | transform.Unmarshal }} {{ index $jsonObj "data" | safeHTML }} {{ end }} {{ else }} {{ errorf "Unable to process math %s \nLikely bad tex" .Inner }} {{ end }}