tocss: Simplify the hugo:vars type handling

Instead of maintaing a list of all CSS units and functions this commit:

* Uses 3 regexps to detect typed CSS values (e.g. `24px`) + properly handle numeric Go types.
* These regexps may have some false positives -- e.g. strings that needs to be quoted.
* For that rare case, you can mark the string with e.g. `"32xxx" | css.Quoted`
* For the opposite case:  `"32" | css.Unquoted`

Updates #10632
This commit is contained in:
Bjørn Erik Pedersen
2023-02-21 18:32:09 +01:00
parent a1a9c08b5f
commit ecf3cd514f
9 changed files with 206 additions and 57 deletions

View File

@@ -63,7 +63,7 @@ type Options struct {
// Vars will be available in 'hugo:vars', e.g:
// @import "hugo:vars";
Vars map[string]string
Vars map[string]any
}
func DecodeOptions(m map[string]any) (opts Options, err error) {