コード例 #1
0
ファイル: tests.py プロジェクト: tex/htmltreediff
def test_parse_text():
    text = 'test one two < & > ;'
    dom = parse_text(text)
    root = dom.documentElement
    assert_equal(len(root.childNodes), 1)
    child = root.childNodes[0]
    assert is_text(child)
    assert child.nodeValue == text
コード例 #2
0
def _is_junk(hashable_node):
    if isinstance(hashable_node, basestring):
        return is_text_junk(hashable_node)
    # Nodes with no text or just whitespace are junk.
    for descendant in walk_dom(hashable_node.node):
        if is_text(descendant):
            if not is_text_junk(descendant.nodeValue):
                return False
    return True
コード例 #3
0
def fuzzy_match_node_hash(node):
    if is_text(node):
        return node.nodeValue
    return FuzzyHashableTree(node)
コード例 #4
0
def match_node_hash(node):
    if is_text(node):
        return node.nodeValue
    return HashableTree(node)
コード例 #5
0
def split_text_nodes(dom):
    for text_node in list(walk_dom(dom)):
        if not is_text(text_node):
            continue
        split_node(text_node)
コード例 #6
0
ファイル: changes.py プロジェクト: iffy/htmltreediff
def split_text_nodes(dom):
    for text_node in list(walk_dom(dom)):
        if not is_text(text_node):
            continue
        split_node(text_node)