Refactor check_nokogiri in msftidy

To avoid looping through the source twice.