Escape <html> elements before passing to Nokogiri::HTML::DocumentFragment.parse to avoid truncation