from research import *
s=begin(1403,'Improve the printable reader page breaks','Can the map and its caption remain together and the introduction avoid the contents page?',{},['model/main_pdf_binding.json','evidence/render_readers.py'])
t=(ROOT/'evidence/render_readers.py').read_text()
t=t.replace("out=ROOT/'deliverables'/(stem+'.pdf')","out=ROOT/'deliverables'/(stem+'_Print.pdf')")
t=t.replace("prepared=work/(args.kind+'.md');prepared.write_text(text)","""if args.kind=='main':
    marker='![Six source routes'
    start=text.index(marker);stop=text.index('## Local changes become',start)
    text=text[:start]+r'\\clearpage'+'\\n\\n'+text[start:stop]+r'\\clearpage'+'\\n\\n'+text[stop:]
prepared=work/(args.kind+'_print.md');prepared.write_text(text)""")
t=t.replace("header.write_text(", "header.write_text(r'\\let\\oldtableofcontents\\tableofcontents'+'\\n'+r'\\renewcommand{\\tableofcontents}{\\oldtableofcontents\\clearpage}'+'\\n'+")
t=t.replace("args.kind+'_pandoc.log'","args.kind+'_print_pandoc.log'")
a=artifact('evidence/render_readers_v2.py',t)
finish(s,{'rendering_pipeline':a,'observed_issue':'Initial PDF split the map caption across pages and mixed contents with the introduction.','retained_previous_pdf':'Original rendered PDF remains unchanged as inspected evidence.'},'The print-specific layout now gives contents and map their own page boundaries, without altering the frozen reader text or overwriting the first rendition.','Render and inspect the improved main reader.',{'new_output':"stem+'_Print.pdf'" in t,'map_break':'marker=' in t and 'clearpage' in t})
