class Canon::Diff::DiffClassifier
def formatting_only_diff?(diff_node)
-
(Boolean)- true if formatting-only
Parameters:
-
diff_node(DiffNode) -- The diff node to check
def formatting_only_diff?(diff_node) # Only apply formatting detection to actual text content differences # If the nodes are not text nodes (e.g., element nodes), don't apply formatting detection node1 = diff_node.node1 node2 = diff_node.node2 # Check if both nodes are text nodes # If not, this is not a formatting-only difference return false unless text_node?(node1) && text_node?(node2) text1 = extract_text_content(diff_node.node1) text2 = extract_text_content(diff_node.node2) # For text_content dimension, use normalized text comparison # This handles cases like "" vs " " (both normalize to "") if diff_node.dimension == :text_content normalized_equivalent?(text1, text2) else FormattingDetector.formatting_only?(text1, text2) end end