module Loofah::HtmlDocumentBehavior::ClassMethods

def parse(*args, &block)

def parse(*args, &block)
  remove_comments_before_html_element(super)
end

def remove_comments_before_html_element(doc)

replaced, sibling and children nodes can be created).
the contract that scrubbers expect of a node (e.g., it can be
but are not scrubbed by Loofah because these nodes don't meet

https://www.w3.org/TR/html401/struct/global.html#h-7.1

these comments are allowed by the HTML spec:

remove comments that exist outside of the HTML element.
def remove_comments_before_html_element(doc)
  doc.children.each do |child|
    child.unlink if child.comment?
  end
  doc
end