Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file html_output.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136open!Coreopen!Importletstring_of_colorc=letmoduleC=Patdiff_format.Colorinmatchcwith|C.Black->"#000000"|C.Red->"#880000"|C.Green->"#008800"|C.Yellow->"#888800"|C.Blue->"#000088"|C.Magenta->"#880088"|C.Cyan->"#008888"|C.White|C.Default->"#ffffff"|C.Gray->"#c0c0c0"|C.Bright_black->"#c0c0c0"|C.Bright_red->"#FF0000"|C.Bright_green->"#00FF00"|C.Bright_yellow->"#FFFF00"|C.Bright_blue->"#0000FF"|C.Bright_magenta->"#FF00FF"|C.Bright_cyan->"#00FFFF"|C.Bright_white->"#FFFFFF"|C.RGB6{r;g;b}->letpercentx=float(x*100)/.5.0insprintf"rgb(%f%%,%f%%,%f%%)"(percentr)(percentg)(percentb)|C.Gray24{level}->letpercent=float(level*100)/.23.0insprintf"rgb(%f%%,%f%%,%f%%)"percentpercentpercent;;moduleStyle=structletapplytext~styles=letmoduleS=Patdiff_format.Styleinletstart_tags,end_tags=List.foldstyles~init:([],[])~f:(fun(s,e)style->matchstylewith|S.Bold->"<span style=\"font-weight:bold\">"::s,"</span>"::e|S.Reset->s,e|S.Foregroundc|S.Fgc->sprintf"<span style=\"color:%s\">"(string_of_colorc)::s,"</span>"::e|S.Backgroundc|S.Bgc->(sprintf"<span style=\"background-color:%s\">"(string_of_colorc)::s,"</span>"::e)|S.Underline|S.Emph->"<u>"::s,"</u>"::e|S.Blink->"<span style=\"text-decoration:blink\">"::s,"</span>"::e|S.Inverse->s,e|S.Hide->"<!-- "::s," -->"::e|S.Dim->(* "<span style=\"font-weight:lighter\">"::s, "</span>"::e *)(sprintf"<span style=\"color:%s\">"(string_of_colorPatdiff_format.Color.Gray)::s,"</span>"::e))inletlst=start_tags@[text]@end_tagsinString.concat~sep:""lst;;end(* assuming we only insert text in contents and not in attributes, only escaping these
three characters should be enough. We may want to print differently non printable
ascii characters too? *)lethtml_escape_char=function|'<'->"<"|'>'->">"|'&'->"&"|c->String.of_charc;;lethtml_escapes=String.concat_maps~f:html_escape_charmoduleRule=structletapplytext~rule~refined=letmoduleR=Patdiff_format.RuleinletmoduleA=Patdiff_format.Rule.Annexinletapplystylestext=Style.applytext~stylesinsprintf"%s%s%s"(applyrule.R.pre.A.stylesrule.R.pre.A.text)(ifrefinedthenapply[Patdiff_format.Style.Reset]textelseapplyrule.R.styles(html_escapetext))(applyrule.R.suf.A.stylesrule.R.suf.A.text);;endletprint_header~rules~file_names:(prev_file,next_file)~print=letprint_linefilerule=letget_times=tryTime.to_string(Time.of_span_since_epoch(Time.Span.of_sec(Unix.stats).Unix.st_mtime))with|_e->""inlettime=get_timefileinprint(Rule.apply(file^" "^time)~rule~refined:false)inletmoduleRz=Patdiff_format.Rulesinprint_lineprev_filerules.Rz.header_old;print_linenext_filerules.Rz.header_new;;letprint~print_global_header~file_names~rules~print~location_stylehunks=print"<pre style=\"font-family:consolas,monospace\">";ifprint_global_headerthenprint_header~rules~file_names~print;letfhunk=letmoduleRz=Patdiff_format.RulesinPatdiff_format.Location_style.sprintlocation_stylehunk~prev_filename:(fstfile_names)~rule:(Rule.apply~rule:rules.Rz.hunk~refined:false)|>print;letmoduleR=Patience_diff.Rangeinlethandle_range=function(* Just print the new array elements *)|R.Samer->letmr=Array.mapr~f:sndinArray.itermr~f:print|R.Prevr|R.Nextr|R.Unifiedr->Array.iterr~f:print|R.Replace(ar1,ar2)->Array.iterar1~f:print;Array.iterar2~f:printinList.iterhunk.ranges~f:handle_rangeinList.iterhunks~f;print"</pre>";;