package main import ( "bytes" "flag" "fmt" "html/template" "io/fs" "os" "path/filepath" "regexp" "sort" "strings" "smartbar/internal/config" ) // Expose page size to templates via CSS variables inline on . // Use HTMLAttr so it renders as an attribute safely. func pageSizeStyleAttr(widthIn, heightIn float64) template.HTMLAttr { return template.HTMLAttr( `style="--page-w: ` + floatToIn(widthIn) + `; --page-h: ` + floatToIn(heightIn) + `;"`, ) } func floatToIn(v float64) string { return strings.TrimRight(strings.TrimRight(fmt.Sprintf("%.4fin", v), "0"), ".") } func min(a, b int) int { if a < b { return a } return b } // extractAndScopeCSS extracts `) matches := styleRegex.FindAllStringSubmatch(content, -1) var scopedCSS strings.Builder contentWithoutCSS := content // Remove all