skip_rule.go 504 B

1234567891011121314151617181920212223242526272829303132
  1. package css
  2. import "github.com/gorilla/css/scanner"
  3. func skipRules(s *scanner.Scanner) {
  4. var (
  5. open int
  6. close int
  7. started bool
  8. )
  9. for {
  10. if started && close >= open {
  11. return
  12. }
  13. token := s.Next()
  14. if token.Type == scanner.TokenEOF || token.Type == scanner.TokenError {
  15. return
  16. }
  17. if token.Type == scanner.TokenChar {
  18. if token.Value == "{" {
  19. open++
  20. started = true
  21. continue
  22. }
  23. if token.Value == "}" {
  24. close++
  25. started = true
  26. continue
  27. }
  28. }
  29. }
  30. }