The indent trigger was using .abs() which fired on both increased indent (non-indented → indented) AND decreased indent (indented → non-indented). This caused drop-cap style paragraphs (indented first line, flush-left continuation) to incorrectly split into two blocks. Per plan Phase 4.4 heuristic #2, indent change should only trigger when the current line is MORE indented (to the right, larger x0) than the block average - i.e., a new paragraph starting after non-indented text. It should NOT trigger for decreased indent (first line indented, rest flush-left). Fix: Remove .abs() and only check if line_x0 - block_avg_x0 > threshold. Tests: - test_indented_first_line_new_block: PASS (non-indented → indented splits) - test_indented_first_line_of_paragraph_not_split: PASS (drop cap stays together) - All 179 line module tests: PASS
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import zlib
|
|
|
|
# Read the files
|
|
with open('tests/fingerprint/fixtures/content_edit_one_glyph/v1.pdf', 'rb') as f:
|
|
v1_data = f.read()
|
|
|
|
with open('tests/fingerprint/fixtures/content_edit_one_glyph/v2.pdf', 'rb') as f:
|
|
v2_data = f.read()
|
|
|
|
# Find the stream data
|
|
def extract_stream(pdf_data):
|
|
stream_start = pdf_data.find(b'stream\n') + 7
|
|
endstream_pos = pdf_data.find(b'endstream', stream_start)
|
|
return pdf_data[stream_start:endstream_pos]
|
|
|
|
v1_stream = extract_stream(v1_data)
|
|
v2_stream = extract_stream(v2_data)
|
|
|
|
print('v1 stream hex:', v1_stream.hex())
|
|
print('v2 stream hex:', v2_stream.hex())
|
|
print()
|
|
|
|
# Decompress
|
|
v1_decompressed = zlib.decompress(v1_stream)
|
|
v2_decompressed = zlib.decompress(v2_stream)
|
|
|
|
print('v1 decompressed:', repr(v1_decompressed))
|
|
print('v2 decompressed:', repr(v2_decompressed))
|
|
print()
|
|
|
|
# Hash the decompressed content
|
|
import hashlib
|
|
v1_hash = hashlib.sha256(v1_decompressed).hexdigest()
|
|
v2_hash = hashlib.sha256(v2_decompressed).hexdigest()
|
|
|
|
print('v1 SHA-256:', v1_hash)
|
|
print('v2 SHA-256:', v2_hash)
|
|
print('Different?', v1_hash != v2_hash)
|