get_html_head_tags() + friends (with long-winded explanation)

See in-code comments for details