"""Original CC0 plain text controls; run once without overwriting evidence."""
from pathlib import Path
import hashlib,json
out=Path('benchmarks/fixtures/text-markdown1')
assert not (out/'manifest.json').exists()
corpora={
 'literals': '# literal heading\n\n*asterisks* _underscores_ **stars** ~~tildes~~\n<tag> &copy; &#65; <https://example.test>\n<script>literal_only()</script>\n![image](https://example.test/private.png)\n[link](https://example.test)\n1. literal list\n> literal quote\n---\nCafé Ω Ж 世界 مرحبا 😀 e\u0301\n',
 'whitespace': '\n\tfirst  line  \r\n    four spaces\r\n\r\n\r\nsecond\tcolumn\rlegacy CR\r\n```\r\n~~~~\r\n``````\r\n~~~\r\n  final without newline  ',
}
files={}
for name,text in corpora.items():
 data=text.encode('utf-8');p=out/(name+'.txt');p.write_bytes(data)
 expected=text.replace('\r\n','\n').replace('\r','\n')
 if expected and not expected.endswith('\n'):expected+='\n'
 (out/(name+'.expected.txt')).write_bytes(expected.encode('utf-8'))
 files[p.name]={'bytes':len(data),'sha256':hashlib.sha256(data).hexdigest(),'originalCorpus':name,'encoding':'UTF-8','expected':name+'.expected.txt'}
data=b'\xff\xfe'+corpora['whitespace'].encode('utf-16le');(out/'whitespace-utf16le.txt').write_bytes(data)
files['whitespace-utf16le.txt']={'bytes':len(data),'sha256':hashlib.sha256(data).hexdigest(),'originalCorpus':'whitespace','encoding':'BOM UTF-16LE','expected':'whitespace.expected.txt','derivative':True}
(out/'LICENSE.txt').write_text('CC0 1.0: these original synthetic text corpora are dedicated to the public domain. No user files. example.test URLs are literal non-fetching controls.\n')
(out/'manifest.json').write_text(json.dumps({'license':'CC0-1.0','originalCorpora':2,'encodingDerivatives':1,'contract':'One literal fenced code block; CRLF/CR to LF; final unterminated line gains one LF; no Unicode normalization or trimming.','controls':['Unicode including decomposed accent','literal HTML/entities/Markdown punctuation and URLs','leading/trailing spaces and tabs','leading and repeated blank lines','mixed line endings','both fence characters with longer internal runs','missing final newline'],'files':files},indent=2,ensure_ascii=False)+'\n')
print(json.dumps(files))
