123456789101112131415161718192021222324252627282930313233343536373839404142letoption_of_result=functionResult.Okx->Somex|Result.Error_->Noneletrecflatmap?sep~f=function|[]->[]|[x]->fx|x::xs->(lethd=fxinlettl=flatmap?sep~fxsinmatchsepwithNone->hd@tl|Somesep->hd@sep@tl)letrecskip_until~p=function|[]->[]|h::t->ifphthentelseskip_until~ptletsplit_at~flst=letrecloopacc=function|hd::_asrestwhenfhd->(List.revacc,rest)|[]->(List.revacc,[])|hd::tl->loop(hd::acc)tlinloop[]lstletreccompute_length_source(t:Types.Source.t):int=letf(acc:int)=function|Types.Source.Eltt->acc+compute_length_inlinet|Types.Source.Tag(_,t)->acc+compute_length_sourcetinList.fold_leftf0tandcompute_length_inline(t:Types.Inline.t):int=letf(acc:int){Types.Inline.desc;_}=matchdescwith|Texts->acc+String.lengths|Entity_e->acc+1|Linebreak->0(* TODO *)|Styled(_,t)|Link{content=t;_}->acc+compute_length_inlinet|Sources->acc+compute_length_sources|Math_->assertfalse|Raw_markup_->assertfalse(* TODO *)inList.fold_leftf0t