private static function is_self_closing_tag($tag)
{
// This function is called a lot; the static var prevents having to re-create the array every time.
static $self_closing_tags;
if (!isset($self_closing_tags)) {
// https://www.w3.org/TR/html5/syntax.html#serializing-html-fragments
// Not all are valid AMP, but we include them for completeness.
$self_closing_tags = array('area', 'base', 'basefont', 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr');
}
return in_array($tag, $self_closing_tags);
}