Have got text transformations working

This commit is contained in:
Leon Mika 2025-09-06 11:26:54 +10:00
parent 9f2fa96b92
commit 41daf7cfc9
14 changed files with 178 additions and 17 deletions

22
textfilters.go Normal file
View file

@ -0,0 +1,22 @@
package main
import (
"bytes"
"encoding/json"
"strconv"
)
type TextFilter func(input string) (output string, err error)
var TextFilters = map[string]TextFilter{
"unquote": func(input string) (output string, err error) {
return strconv.Unquote(input)
},
"format-json": func(input string) (output string, err error) {
var dst bytes.Buffer
if err := json.Indent(&dst, []byte(input), "", " "); err != nil {
return "", err
}
return dst.String(), nil
},
}