diff --git a/sizeFunc.go b/sizeFunc.go index cd76fd5..d56b101 100644 --- a/sizeFunc.go +++ b/sizeFunc.go @@ -11,6 +11,10 @@ import ( // "min", "max", "clamp", "sum", "sub", "mul", and "div" functions are available. type SizeFunc interface { fmt.Stringer + // Name() returns the function name: "min", "max", "clamp", "sum", "sub", "mul", or "div" + Name() string + // Args() returns a list of function arguments + Args() []any cssString(session Session) string writeCSS(topFunc string, buffer *strings.Builder, session Session) writeString(topFunc string, buffer *strings.Builder) @@ -159,6 +163,16 @@ func (data *sizeFuncData) String() string { return buffer.String() } +func (data *sizeFuncData) Name() string { + return data.tag +} + +func (data *sizeFuncData) Args() []any { + args := make([]any, len(data.args)) + copy(args, data.args) + return args +} + func (data *sizeFuncData) writeString(topFunc string, buffer *strings.Builder) { buffer.WriteString(data.tag) buffer.WriteRune('(') diff --git a/viewStyle.go b/viewStyle.go index 4adecdc..1abd273 100644 --- a/viewStyle.go +++ b/viewStyle.go @@ -582,7 +582,8 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s } else { for _, ch := range text { if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || - ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' { + ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' || + ch == '#' || ch == '%' || ch == 'π' || ch == '°' { } else { simple = false break @@ -667,7 +668,7 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s value.writeString(buffer, indent+"\t") case fmt.Stringer: - buffer.WriteString(value.String()) + writeString(value.String()) case []ViewShadow: switch len(value) {