591.tag-validator.go 373 B

12345678910111213141516171819202122
  1. func isValid(code string) bool {
  2. st := make([]string, 0)
  3. for i, r := range code {
  4. if 0 < i && len(st) == 0 {
  5. return false
  6. }
  7. if code[i:i+9] == "<![CDATA[" { // Parse cdata
  8. i = strings.Index(code[i+8:], "]]>")
  9. if i < 0 {
  10. return false
  11. }
  12. i += 2
  13. } else if code[i:i+2] == "</" {
  14. name :=
  15. } else if r == '<' {
  16. }
  17. }
  18. return len(st) == 0
  19. }