@@ -52,38 +52,31 @@ func (c *Command) makeProperty(str string) string {
5252 str = mediaRegex .ReplaceAllString (str , "" )
5353 str = prefixRegex .ReplaceAllString (str , "" )
5454
55- strict := false
56- separator := "-"
57- if strings .Contains (str , "~" ) {
58- strict = true
59- separator = "~"
60- }
61-
6255 // First check for color patterns like "color-red-400"
6356 colorStr , isColor := c .makeColor (str )
6457 if isColor {
6558 return colorStr
6659 }
6760
68- // Split the string by the separator
69- parts := strings .Split (str , separator )
61+ // Split by - to get parts
62+ parts := strings .Split (str , "-" )
7063 if len (parts ) <= 1 {
7164 return str
7265 }
7366
7467 // Find the first part that contains a number
7568 propertyEndIdx := - 1
7669 for i , part := range parts {
77- // Check if this part contains a number
78- if regexp .MustCompile (`\d` ).MatchString (part ) {
70+ // Check if this part contains a number (either directly or after ~)
71+ if regexp .MustCompile (`\d` ).MatchString (part ) || ( strings . Contains ( part , "~" ) && regexp . MustCompile ( `\d` ). MatchString ( strings . Split ( part , "~" )[ 1 ])) {
7972 propertyEndIdx = i
8073 break
8174 }
8275 }
8376
8477 // If no number found, use traditional approach with last part as value
8578 if propertyEndIdx == - 1 {
86- last := strings .LastIndex (str , separator )
79+ last := strings .LastIndex (str , "-" )
8780 if last == - 1 {
8881 return str
8982 }
@@ -93,26 +86,49 @@ func (c *Command) makeProperty(str string) string {
9386 // Join parts before the property end to form the property name
9487 property := strings .Join (parts [:propertyEndIdx ], "-" )
9588
96- // For strict values, just join remaining parts with spaces
97- if strict {
98- valueStr := strings .Join (parts [propertyEndIdx :], " " )
99- return property + ":" + valueStr
100- }
101-
10289 // Process each value part individually
10390 valueParts := parts [propertyEndIdx :]
10491 processedValues := make ([]string , len (valueParts ))
10592
10693 for i , part := range valueParts {
107- // Try to convert to number
108- numValue , err := strconv .Atoi (part )
109- if err == nil {
110- // It's a number, apply divider and unit
111- val := float32 (numValue ) / float32 (c .Config .Divider )
112- processedValues [i ] = fmt .Sprintf ("%v%s" , val , c .Config .Unit )
94+ // Check if this part contains a ~ for strict value
95+ if strings .Contains (part , "~" ) {
96+ // Split by ~ and take the strict value
97+ strictParts := strings .Split (part , "~" )
98+
99+ // First part could be empty if ~ is at the beginning
100+ if strictParts [0 ] != "" {
101+ // First part is not strict, process normally
102+ numValue , err := strconv .Atoi (strictParts [0 ])
103+ if err == nil {
104+ // It's a number, apply divider and unit
105+ val := float32 (numValue ) / float32 (c .Config .Divider )
106+ processedValues [i ] = fmt .Sprintf ("%v%s" , val , c .Config .Unit )
107+ } else {
108+ // Not a number, keep as is
109+ processedValues [i ] = strictParts [0 ]
110+ }
111+ }
112+
113+ // Second part is strict, don't apply divider or unit
114+ if len (strictParts ) > 1 {
115+ if processedValues [i ] != "" {
116+ processedValues [i ] += " " + strictParts [1 ]
117+ } else {
118+ processedValues [i ] = strictParts [1 ]
119+ }
120+ }
113121 } else {
114- // Not a number, keep as is
115- processedValues [i ] = part
122+ // No ~ in this part, process normally
123+ numValue , err := strconv .Atoi (part )
124+ if err == nil {
125+ // It's a number, apply divider and unit
126+ val := float32 (numValue ) / float32 (c .Config .Divider )
127+ processedValues [i ] = fmt .Sprintf ("%v%s" , val , c .Config .Unit )
128+ } else {
129+ // Not a number, keep as is
130+ processedValues [i ] = part
131+ }
116132 }
117133 }
118134
0 commit comments