Best way to find if a valid script tag exists inside an HTML file


I have a formatting package that I would like to add the ability to format JS inside script tags in an HTML file. However, I don’t want to just do something like String.indexOf() or Regex.test() because it will get slower on bigger and bigger files. Is there an AST that Atom creates or something similar that I can make use of to see whether there is valid <script></script> in a file?