def find_and_patch_entry(soup, entry):
link = soup.find("<STR_LIT:a>", {"<STR_LIT:class>": "<STR_LIT>"}, href="<STR_LIT:#>" + entry.anchor)<EOL>tag = soup.new_tag("<STR_LIT:a>")<EOL>tag["<STR_LIT:name>"] = APPLE_REF_TEMPLATE.format(entry.type, entry.name)<EOL>if link:<EOL><INDENT>link.parent.insert(<NUM_LIT:0>, tag)<EOL>return True<EOL><DEDENT>elif entry.anchor.startswith("<STR_LIT>"):<EOL><INDENT>soup.h1.parent.insert(<NUM_LIT:0>, tag)<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>
Modify soup so Dash.app can generate TOCs on the fly.