Add new function insert_before and use cgi.escape for escaping text