formatting
modified parse_title and parse_string to use callbacks, to simplify code in parse_document