diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-08-07 10:40:54 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-08-09 17:18:37 +0200 |
commit | 33c0938cd50dd3409f8e94878b97d789cc328f23 (patch) | |
tree | fc4cc45265b86746aa37bc3ab4445724d22a98f2 /tpl/transform/transform_integration_test.go | |
parent | 0c3a1c7288032401327a9c4d7044e297bf3f7da6 (diff) | |
download | hugo-33c0938cd50dd3409f8e94878b97d789cc328f23.tar.gz hugo-33c0938cd50dd3409f8e94878b97d789cc328f23.zip |
Add build time math rendering
While very useful on its own (and combined with the passthrough render hooks), this also serves as a proof of concept of using WASI (WebAssembly System Interface) modules in Hugo.
This will be marked _experimental_ in the documentation. Not because it will be removed or changed in a dramatic way, but we need to think a little more how to best set up/configure similar services, define where these WASM files gets stored, maybe we can allow user provided WASM files plugins via Hugo Modules mounts etc.
See these issues for more context:
* https://github.com/gohugoio/hugo/issues/12736
* https://github.com/gohugoio/hugo/issues/12737
See #11927
Diffstat (limited to 'tpl/transform/transform_integration_test.go')
-rw-r--r-- | tpl/transform/transform_integration_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tpl/transform/transform_integration_test.go b/tpl/transform/transform_integration_test.go index 351420a67..529f18a5f 100644 --- a/tpl/transform/transform_integration_test.go +++ b/tpl/transform/transform_integration_test.go @@ -133,3 +133,20 @@ Scar,"a "dead cat",11 [[name description age] [Spot a nice dog 3] [Rover a big dog 5] [Felix a "malicious" cat 7] [Bella an "evil" cat 9] [Scar a "dead cat 11]] `) } + +func TestToMath(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableKinds = ['page','rss','section','sitemap','taxonomy','term'] +-- layouts/index.html -- +{{ $result := transform.ToMath "c = \\pm\\sqrt{a^2 + b^2}" }} +{{ printf "%v" $result | safeHTML }} + ` + b := hugolib.Test(t, files) + + b.AssertFileContent("public/index.html", ` +<span class="katex"><math + `) +} |