// for markdown hr#lethorizontalrule=line(start:(25%,0%),end:(75%,0%))// definition list styling#showterms:it=>{it.children.map(child=>[#strong[#child.term]#block(inset:(left:1.5em))[#child.description]]).join()}// author parsing#letauthors_oneline=cfg.authors.map(a=>a.name).join(", ")#ifauthors_oneline==none{authors_oneline=""}#letauthors_name_array=cfg.authors.map(a=>a.name)#letdisable-header=cfg.disable-header#letdisable-footer=cfg.disable-footer#letfont=cfg.font#letheader-footer-font=cfg.header-footer-font#letreplace_header_content(content)={ifcontent!=none{ifcontent=="%page%"{letboth=context{page.numbering.clusters().filter(c=>(cin("1","a","A","i","I","α","Α","*","א","一","壹","あ","い","ア","イ","ㄱ","가","\u{0661}","\u{06F1}","\u{0967}","\u{09E7}","\u{0995}","①","⓵",))).len()ifboth>=2{returncontextcounter(page).display(page.numbering,both:true)}}returncontextcounter(page).display(page.numbering)}returncontent.replace("%title%",cfg.title).replace("%date%",cfg.date.display(cfg.dateformat)).replace("%author%",authors_oneline)}}#(cfg.header-left=replace_header_content(cfg.header-left))#(cfg.header-center=replace_header_content(cfg.header-center))#(cfg.header-right=replace_header_content(cfg.header-right))#(cfg.footer-left=replace_header_content(cfg.footer-left))#(cfg.footer-center=replace_header_content(cfg.footer-center))#(cfg.footer-right=replace_header_content(cfg.footer-right))// Define a helper for the header#letmake-header()=context{ifdisable-header!=true[#settext(font:header-footer-font)#grid(columns:(auto,1fr,auto),align:(left,center,right),cfg.header-left,cfg.header-center,cfg.header-right,)#v(-par.spacing+0.5em)#line(length:100%,stroke:cfg.header-footer-stroke)]else[]}// Define a helper for the footer#letfooter-left()={letfl=cfg.footer-leftiflower(fl)=="none"{returnnone}else{returnfl}}#letfooter-right()={letfr=cfg.footer-rightiflower(fr)=="none"{returnnone}else{returnfr}}#letmake-footer()=context{ifdisable-footer!=true[#settext(font:header-footer-font)#line(length:100%,stroke:cfg.header-footer-stroke)#v(-par.spacing+0.5em)#grid(columns:(auto,1fr,auto),align:(left,center,right),footer-left(),cfg.footer-center,footer-right(),)]else[]}// setting pdf meta data#setdocument(title:cfg.title,keywords:cfg.keywords,date:cfg.date,author:authors_name_array,)#letmargin=cfg.margin#ifdisable-header==true{margin=(x:margin.x,top:margin.top-3em,bottom:margin.bottom)}#ifdisable-footer==true{margin=(x:margin.x,top:margin.top,bottom:margin.bottom-3em)}#setpage(paper:cfg.paper,margin:margin,numbering:cfg.page-numbering,)#letleading=cfg.leading#setpar(justify:cfg.justify,leading:leading,spacing:cfg.spacing,)#letfontsize=cfg.fontsize#settext(lang:cfg.lang,region:cfg.region,font:font,size:fontsize,)// set heading styles#letnumbering=none#ifcfg.number-sections{numbering=cfg.section-numbering}#setheading(numbering:numbering)#showheading:settext(font:cfg.heading-font)#showheading.where(level:1):settext(fontsize*1.3)#showheading.where(level:1):setblock(above:2.65em,below:1.75em)#showheading.where(level:2):settext(fontsize*1.1)#showheading.where(level:2):setblock(above:2em,below:1.375em)#showheading.where(level:3):setblock(above:2em,below:1em)// set figure styles#showfigure:setblock(above:2em,below:2em)#showfigure.where(kind:table):setfigure.caption(position:top)#showfigure.where(kind:table):setfigure(supplement:cfg.table-prefix)#showfigure.where(kind:image):setfigure.caption(position:bottom)#showfigure.where(kind:image):setfigure(supplement:cfg.figure-prefix)// listings#showfigure.where(kind:raw):setfigure.caption(position:bottom)#showfigure.where(kind:raw):setfigure(supplement:cfg.listing-prefix)#showfigure.where(kind:raw):setalign(left)// set captions to left#showfigure.caption:setalign(left)// indent lists#showlist:setlist(indent:6pt)#showenum:setenum(indent:6pt)// table styling#lettable-stroke=(x,y)=>(left:ifx==0{cfg.table-stroke-border-x}else{cfg.table-stroke-vertical},right:cfg.table-stroke-border-x,top:ify==0{cfg.table-stroke-border-y}elseify==1{cfg.table-stroke-header-b}else{cfg.table-stroke-horizontal},bottom:cfg.table-stroke-border-y,x:cfg.table-stroke-vertical,y:cfg.table-stroke-horizontal,)// fill for striped tables#letstriped=(x,y)=>{ify==0{cfg.table-header-bg}elseifcalc.even(y)andy>1{cfg.table-striped-bg}else{none}}#lettable-fill=(x,y)=>{ify==0{cfg.table-header-bg}else{none}}#settable(stroke:table-stroke,inset:cfg.table-inset,fill:table-fill,)#showtable:setpar(justify:false,linebreaks:"optimized")#showtable:settext(hyphenate:true,costs:(hyphenation:100000%))// set smart quotes#setsmartquote(enabled:cfg.smartquote)// reduce code line spacing#showraw.where(block:true):settext(1em/0.9)#showraw:settext(ligatures:true,font:cfg.code-font)