from pathlib import Path
import json,base64,hashlib
root=Path('benchmarks/fixtures/text-image1');root.mkdir(exist_ok=False);sha=lambda b:hashlib.sha256(b).hexdigest();rows=[]
text='Plain page proof — Ω Ж ∫\r\n\r\n'+'\r\n'.join(f'Line {i:03d}: literal **stars** <tag> &amp;   three spaces; Ω Ж.'for i in range(1,81))+'\r\nTerminal line 081.\r\n';(root/'pages.txt').write_bytes(text.encode())
image=Path('benchmarks/fixtures/text-office1/original.png').read_bytes();md='# Paginated Markdown proof Ω Ж\n\n![Original arithmetic picture](data:image/png;base64,'+base64.b64encode(image).decode()+')\n\n'+'\n\n'.join(f'Row {i:03d}: **source order** and *emphasis* with `literal <tag>`.'for i in range(1,76))+'\n\nTerminal Markdown row 076.\n';(root/'pages.md').write_bytes(md.encode())
for n,from_,intents in [('pages.txt','txt',[f'Line {i:03d}:'for i in range(1,81)]+['Terminal line 081.']),('pages.md','md',[f'Row {i:03d}:'for i in range(1,76)]+['Terminal Markdown row 076.'])]:
 b=(root/n).read_bytes();rows.append(dict(id=n,from_=from_,file=str(root/n),original=True,license='CC0-1.0',provenance='Original arithmetic/numbered synthetic text authored for this repository. No user or external copyrighted files.',bytes=len(b),sha256=sha(b),orderedAnchors=intents,minimumPdfPages=2))
for name in ['semantic','holdout']:
 p=Path('benchmarks/fixtures/text-office1/'+name+'.md');b=p.read_bytes();rows.append(dict(id=name+'.md',from_='md',file=str(p),original=False,license='CC0-1.0',provenance='Unchanged original text-office1 corpus reused; not a new original fixture.',bytes=len(b),sha256=sha(b),minimumPdfPages=1))
rows[0]['expectedLogicalText']='Plain page proof — Ω Ж ∫'+''.join(f'Line {i:03d}: literal **stars** <tag> &amp;   three spaces; Ω Ж.'for i in range(1,81))+'Terminal line 081.'
rows[1]['expectedLogicalText']='Paginated Markdown proof Ω Ж'+''.join(f'Row {i:03d}: source order and emphasis with literal <tag>.'for i in range(1,76))+'Terminal Markdown row 076.'
(root/'manifest.json').write_text(json.dumps(dict(license='CC0-1.0',newOriginalCorpora=2,reusedOriginalCorpora=2,encodingDerivatives=0,rows=rows,ancillaryReusedPicture=dict(file='benchmarks/fixtures/text-office1/original.png',bytes=len(image),sha256=sha(image),license='CC0-1.0')),ensure_ascii=False,indent=2)+'\n')
