Esempio n. 1
0
def dom_diff(old_dom, new_dom):
    # Split all the text nodes in the old and new dom.
    split_text_nodes(old_dom)
    split_text_nodes(new_dom)

    # Get the edit script from the diff algorithm
    differ = Differ(old_dom, new_dom)
    edit_script = differ.get_edit_script()
    # Run the edit script, then use the inserted and deleted nodes metadata to
    #     show changes.
    runner = EditScriptRunner(old_dom, edit_script)
    dom = runner.run_edit_script()
    add_changes_markup(dom, runner.ins_nodes, runner.del_nodes)
    return dom
Esempio n. 2
0
def dom_diff(old_dom, new_dom):
    # Split all the text nodes in the old and new dom.
    split_text_nodes(old_dom)
    split_text_nodes(new_dom)

    # Get the edit script from the diff algorithm
    differ = Differ(old_dom, new_dom)
    edit_script = differ.get_edit_script()
    # Run the edit script, then use the inserted and deleted nodes metadata to
    #     show changes.
    runner = EditScriptRunner(old_dom, edit_script)
    dom = runner.run_edit_script()
    add_changes_markup(dom, runner.ins_nodes, runner.del_nodes)
    return dom
Esempio n. 3
0
def html_patch(old_html, edit_script):
    old_dom = parse_minidom(old_html)
    split_text_nodes(old_dom)
    runner = EditScriptRunner(old_dom, edit_script)
    return minidom_tostring(runner.run_edit_script())
Esempio n. 4
0
def html_patch(old_html, edit_script):
    old_dom = parse_minidom(old_html)
    split_text_nodes(old_dom)
    runner = EditScriptRunner(old_dom, edit_script)
    return minidom_tostring(runner.run_edit_script())