Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file raw.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208(** Raw latex primitives:
- macro definitions
- env defitions
- text escaping
*)typepr=Format.formatter->unittype'awith_options=?options:prlist->'atype('a,'b)tr='aFmt.t->'bFmt.ttype'at=('a,'a)trmoduleEscape=structlettext~code_hyphenation=letb=Buffer.create17infuns->fori=0toString.lengths-1domatchs.[i]with|'{'->Buffer.add_stringb"\\{"|'}'->Buffer.add_stringb"\\}"|'\\'->Buffer.add_stringb"\\textbackslash{}"|'%'->Buffer.add_stringb"\\%"|'~'->Buffer.add_stringb"\\textasciitilde{}"|'^'->Buffer.add_stringb"\\textasciicircum{}"|'_'->ifcode_hyphenationthenBuffer.add_stringb{|\_\allowbreak{}|}elseBuffer.add_stringb{|\_|}|'.'whencode_hyphenation->Buffer.add_stringb{|.\allowbreak{}|}|';'whencode_hyphenation->Buffer.add_stringb{|;\allowbreak{}|}|','whencode_hyphenation->Buffer.add_stringb{|,\allowbreak{}|}|'&'->Buffer.add_stringb"\\&"|'#'->Buffer.add_stringb"\\#"|'$'->Buffer.add_stringb"\\$"|c->Buffer.add_charbcdone;lets=Buffer.contentsbinBuffer.resetb;sletpp~code_hyphenationppfx=Format.pp_print_stringppf(text~code_hyphenationx)letrefppfs=fori=0toString.lengths-1domatchs.[i]with|'~'->Fmt.pfppf"+t+"|'_'->Fmt.pfppf"+u+"|'+'->Fmt.pfppf"+++"|c->Fmt.pfppf"%c"cdoneendletoptionppfpp=Fmt.pfppf"[%t]"ppletcreatename?(options=[])ppppfcontent=Fmt.pfppf{|\%s%a{%a}|}name(Fmt.listoption)optionsppcontentletmathnameppf=Fmt.pfppf{|$\%s$|}nameletcreate2name?(options=[])pp_xpp_yppfxy=Fmt.pfppf{|\%s%a{%a}{%a}|}name(Fmt.listoption)optionspp_xxpp_yyletbindppxppf=ppppfxletlabelppf=create"label"Escape.refppfletmbegin?options=create"begin"?optionsFmt.stringletmend=create"end"Fmt.stringletcode_fragmentpp=create"ocamlcodefragment"ppletbreakppflevel=letpre:_format6=matchlevelwith|Types.Aesthetic->"%%"|Line->{|\\|}|Separation->{|\medbreak|}|_->""inletpost:_format6=matchlevelwith|Types.Line|Separation|Aesthetic|Simple->""|Paragraph->"@,"inFmt.pfppf(pre^^"@,"^^post)letenvnamepp?(with_break=false)?(opts=[])?(args=[])ppfcontent=mbeginppfname;List.iter(Fmt.pfppf"[%t]")opts;List.iter(Fmt.pfppf"{%t}")args;ppppfcontent;mendppfname;breakppf(ifwith_breakthenSimpleelseAesthetic)letindentppppfx=env"ocamlindent"ppppfxletinline_codepp=create"ocamlinlinecode"ppletverbatimppfx=env"verbatim"Fmt.stringppfxletpageref_starx=create"pageref*"Escape.refxlethyperrefs=create"hyperref"~options:[bindEscape.refs]letrefx=create"ref"Escape.refxletemphpp=create"emph"ppletboldpp=create"bold"ppletsubscriptpp=create"textsubscript"ppletsuperscriptpp=create"textsuperscript"ppletcode_blockppppfx=letname="ocamlcodeblock"inmbeginppfname;Fmt.cutppf();ppppfx;Fmt.cutppf();mendppfnameletsectionpp=create"section"ppletsubsectionpp=create"subsection"ppletsubsubsectionpp=create"subsubsection"ppletparagraphpp=create"paragraph"ppletenumerateppppfx=env"enumerate"ppppfxletitemizeppppfx=env"itemize"ppppfxletraw_descriptionppppfx=env"description"ppppfxlethrefxppppfy=create2"href"(Escape.pp~code_hyphenation:false)ppppfxyletitem?options=create"item"?optionsletdescriptionppppfx=(* printing description inside a group make them more robust *)letgroup_printerdppf=Fmt.pfppf"{%a}"ppdinleteltppf(d,elt)=item~options:[group_printerd]ppppfeltinletallppfx=Fmt.pfppf{|\kern-\topsep
\makeatletter\advance\%@topsepadd-\topsep\makeatother%% topsep is hardcoded
|};Fmt.list~sep:(funppf()->breakppfAesthetic)eltppfxinmatchxwith|[]->()(* empty description are not supported *)|_::_->raw_descriptionallppfxleturlppfs=create"url"Fmt.stringppf(Escape.text~code_hyphenation:falses)letfootnotex=create"footnote"urlxletrightarrowppf=math"rightarrow"ppf(** Latex uses forward slash even on Windows. *)letlatex_pathppfpath=letpath_s=String.concat"/"(Fpath.segspath)inFmt.stringppfpath_sletinputppfx=create"input"latex_pathppfxletocamltabular~column_descppppfx=env"ocamltabular"~args:[column_desc]ppppfxletsmall_tableppppftbl=letcolumns=List.length(List.hdtbl)inletrowppfx=letampersandppf()=Fmt.pfppf"& "inFmt.list~sep:ampersandppppfx;breakppfLineinletmatrixppfm=List.iter(rowppf)minletrecrepeatnsppf=ifn=0then()elseFmt.pfppf"%t%t"s(repeat(n-1)s)inletcellppf=Fmt.pfppf"p{%.3f\\textwidth}"(1.0/.float_of_intcolumns)inlettableppftbl=ocamltabular~column_desc:(repeatcolumnscell)matrixppftblin(* we add line breaks to never insert tables between delimiters,
to avoid rendering:
| `A
[ | `B ]
| `C
or
field_1: int;
{ field_2: int; }
field_3: int;
*)breakppfLine;tableppftbl;breakppfLineletocamltagtagppppfx=create2"ocamltag"Fmt.stringppppftagx