"""Offline Pandoc fixtures and commands; all writes stay under this lab.""" from pathlib import Path import subprocess, json, time, sys lab=Path(__file__).resolve().parent corpus=lab/'corpus' source='''--- title: Dialect probe author: Ada --- # Export probe {#probe} The review keeps each documented claim beside its source. A note stays attached to this sentence.[^audit] [^audit]: Compare the exported table with the source. Term : A definition with a concrete meaning. | Route | Result | |:------|-------:| | Local | Kept | | Remote | Review | ```python print("hello") ``` Inline math: $x^2$. $$ y = mx + b $$ ''' (corpus/'dialect.md').write_text(source) truth={'kind':'doc','format':'markdown','headings':[{'level':1,'text':'Export probe'}],'paragraphs':['The review keeps each documented claim beside its source.'],'tables':[{'header':['Route','Result'],'rows':[['Local','Kept'],['Remote','Review']]}],'code_blocks':[['print("hello")']]} (corpus/'dialect.truth.json').write_text(json.dumps(truth,indent=2)) merged='
SubjectGrade
PhysicsPracticalA
TheoryB+
\n' (corpus/'issue-11128.html').write_text(merged) (corpus/'issue-11128.truth.json').write_text(json.dumps({'kind':'doc','format':'html','tables':[{'header':['Subject','Grade'],'rows':[['Physics','Practical','A'],['Theory','B+']]}]},indent=2)) runs=json.loads((lab/'runs.json').read_text()) version=subprocess.check_output(['pandoc','--version'],text=True).splitlines()[0].split()[1] records=[] def run(tool,sample,argv,filename): out=lab/tool/filename;out.parent.mkdir(exist_ok=True) t=time.perf_counter();p=subprocess.run(argv,capture_output=True,text=True,cwd=lab);dt=time.perf_counter()-t out.write_text(p.stdout) records.append({'tool':tool,'sample':sample,'output':str(out.relative_to(lab)),'elapsed_s':round(dt,4),'error':None if p.returncode==0 else p.stderr}) return {'argv':argv,'cwd':'lab','output':str(out.relative_to(lab)),'exit_code':p.returncode,'stderr':p.stderr,'elapsed_s':round(dt,4)} commands=[] for target in ['markdown','gfm','commonmark']: commands.append(run('pandoc-'+target,'dialect',['pandoc','-f','markdown','-t',target,'--wrap=none','corpus/dialect.md'],'dialect.md')) commands.append(run('pandoc-'+target,'issue-11128',['pandoc','-f','html','-t',target,'--wrap=none','corpus/issue-11128.html'],'issue-11128.md')) commands.append(run('pandoc-strict-pipe','issue-11128',['pandoc','-f','html','-t','markdown_strict+pipe_tables-raw_html','--wrap=none','corpus/issue-11128.html'],'issue-11128.md')) # Additional copyable article commands, on the same fixture. extra=[['pandoc','--list-input-formats'],['pandoc','--list-extensions=markdown'],['pandoc','--list-extensions=gfm'],['pandoc','-f','markdown','-t','native','corpus/dialect.md'],['pandoc','-f','markdown','-t','html','--standalone','corpus/dialect.md'],['pandoc','-f','markdown','-t','gfm','--wrap=none','--standalone','corpus/dialect.md'],['pandoc','-f','pdf','-t','gfm','corpus/scan-image.pdf']] for i,argv in enumerate(extra): p=subprocess.run(argv,capture_output=True,text=True,cwd=lab) f=lab/'pandoc-checks'/f'command-{i}.txt';f.parent.mkdir(exist_ok=True);f.write_text(p.stdout+p.stderr) commands.append({'argv':argv,'output':str(f.relative_to(lab)),'exit_code':p.returncode,'stderr':p.stderr}) tools={r['tool'] for r in records} runs['results']=[r for r in runs['results'] if r['tool'] not in tools]+records for t in tools:runs['tools'][t]={'version':version,'device':'cpu','elapsed_s':round(sum(r['elapsed_s'] for r in records if r['tool']==t),4),'error':None} (lab/'runs.json').write_text(json.dumps(runs,indent=1)+'\n') (lab/'pandoc-commands.json').write_text(json.dumps({'python':sys.version,'date':'2026-10-18','pandoc':version,'commands':commands},indent=2)+'\n') for t in tools:print(t, (lab/t/('dialect.md' if (lab/t/'dialect.md').exists() else 'issue-11128.md')).read_text())