diff --git a/jsonte/custom_processor.go b/jsonte/custom_processor.go index 8f94dd8..c5a0551 100644 --- a/jsonte/custom_processor.go +++ b/jsonte/custom_processor.go @@ -39,6 +39,7 @@ func ProcessMCFunction(input string, scope types.JsonObject) (string, error) { // ProcessString processes a string replacing all the jsonte expressions with their values func ProcessString(input string, scope types.JsonObject, startToken, endToken string) (string, error) { + runes := []rune(input) templateMatches, err := FindTemplateMatches(input, startToken, endToken) if err != nil { return "", burrito.PassError(err) @@ -49,7 +50,7 @@ func ProcessString(input string, scope types.JsonObject, startToken, endToken st lastMatchEnd := 0 for _, match := range templateMatches { if match.Start > lastMatchEnd { - sb.WriteString(input[lastMatchEnd:match.Start]) + sb.WriteString(string(runes[lastMatchEnd:match.Start])) } result, err := Eval(match.Match, globalScope, "#") if err != nil { @@ -65,7 +66,6 @@ func ProcessString(input string, scope types.JsonObject, startToken, endToken st return "", burrito.WrappedErrorf("The expression '%s' evaluated to an action.", match.EscapedMatch) } } - runes := []rune(input) if lastMatchEnd < len(runes) { sb.WriteString(string(runes[lastMatchEnd:])) } diff --git a/test/mcfunction_test.go b/test/mcfunction_test.go index c3f1fb6..6362fc8 100644 --- a/test/mcfunction_test.go +++ b/test/mcfunction_test.go @@ -74,7 +74,9 @@ func TestMCFunctionNormalComment(t *testing.T) { } func TestMCFunctionEmoji(t *testing.T) { - f := `#{'emoji:🤣'}` - expected := `emoji:🤣` + f := `# 🔥 +#{'emoji:🤣'}` + expected := `# 🔥 +emoji:🤣` assertMCFunction(t, f, expected) }