Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file html_output.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132open!Coreopen!Importletstring_of_color:Patdiff_format.Color.t->string=function|Black->"#000000"|Red->"#880000"|Green->"#008800"|Yellow->"#888800"|Blue->"#000088"|Magenta->"#880088"|Cyan->"#008888"|White|Default->"#ffffff"|Gray->"#c0c0c0"|Bright_black->"#c0c0c0"|Bright_red->"#FF0000"|Bright_green->"#00FF00"|Bright_yellow->"#FFFF00"|Bright_blue->"#0000FF"|Bright_magenta->"#FF00FF"|Bright_cyan->"#00FFFF"|Bright_white->"#FFFFFF"|RGB6{r;g;b}->letpercentx=float(x*100)/.5.0insprintf"rgb(%f%%,%f%%,%f%%)"(percentr)(percentg)(percentb)|Gray24{level}->letpercent=float(level*100)/.23.0insprintf"rgb(%f%%,%f%%,%f%%)"percentpercentpercent;;moduleStyle=structletapplytext~styles=letstart_tags,end_tags=List.foldstyles~init:([],[])~f:(fun(s,e)style->match(style:Patdiff_format.Style.t)with|Bold->"<span style=\"font-weight:bold\">"::s,"</span>"::e|Reset->s,e|Foregroundc|Fgc->sprintf"<span style=\"color:%s\">"(string_of_colorc)::s,"</span>"::e|Backgroundc|Bgc->(sprintf"<span style=\"background-color:%s\">"(string_of_colorc)::s,"</span>"::e)|Underline|Emph->"<u>"::s,"</u>"::e|Blink->"<span style=\"text-decoration:blink\">"::s,"</span>"::e|Inverse->s,e|Hide->"<!-- "::s," -->"::e|Dim->(* "<span style=\"font-weight:lighter\">"::s, "</span>"::e *)(sprintf"<span style=\"color:%s\">"(string_of_colorGray)::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:Patdiff_format.Rule.t)~refined=letapplystylestext=Style.applytext~stylesinsprintf"%s%s%s"(applyrule.pre.stylesrule.pre.text)(ifrefinedthenapply[Patdiff_format.Style.Reset]textelseapplyrule.styles(html_escapetext))(applyrule.suf.stylesrule.suf.text);;endletprint_header~(rules:Patdiff_format.Rules.t)~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)inprint_lineprev_filerules.header_prev;print_linenext_filerules.header_next;;letprint~print_global_header~file_names~(rules:Patdiff_format.Rules.t)~print~location_stylehunks=print"<pre style=\"font-family:consolas,monospace\">";ifprint_global_headerthenprint_header~rules~file_names~print;letfhunk=Patdiff_format.Location_style.sprintlocation_stylehunk~prev_filename:(fstfile_names)~rule:(Rule.apply~rule:rules.hunk~refined:false)|>print;lethandle_range:stringPatience_diff.Range.t->unit=function(* Just print the new array elements *)|Samer->letmr=Array.mapr~f:sndinArray.itermr~f:print|Prevr|Nextr|Unifiedr->Array.iterr~f:print|Replace(ar1,ar2)->Array.iterar1~f:print;Array.iterar2~f:printinList.iterhunk.ranges~f:handle_rangeinList.iterhunks~f;print"</pre>";;