1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162(** HTML combinators.
This module provides combinators to produce html. It doesn't enforce the
well-formedness of the html, unlike Tyxml, but it's simple and should be
reasonably efficient.
@since 0.12 *)includeHtml_(** @inline *)(** Write an HTML element to this output.
@param top
if true, add DOCTYPE at the beginning. The top element should then be a
"html" tag.
@since 0.14 *)letto_output?(top=false)(self:elt)(out:#IO.Output.t):unit=letout=Out.create_of_outoutiniftopthenOut.add_stringout"<!DOCTYPE html>\n";selfout;Out.add_format_nlout;Out.flushout(** Convert a HTML element to a string.
@param top
if true, add DOCTYPE at the beginning. The top element should then be a
"html" tag. *)letto_string?top(self:elt):string=letbuf=Buffer.create64inletout=IO.Output.of_bufferbufinto_output?topselfout;Buffer.contentsbuf(** Convert a list of HTML elements to a string. This is designed for fragments
of HTML that are to be injected inside a bigger context, as it's invalid to
have multiple elements at the toplevel of a HTML document. *)letto_string_l(l:eltlist)=letbuf=Buffer.create64inletout=Out.create_of_bufferbufinList.iter(funf->fout;Out.add_format_nlout)l;Buffer.contentsbufletto_string_top=to_string~top:true(** Write a toplevel element to an output channel.
@since 0.14 *)letto_out_channel_top=to_output~top:true(** Produce a streaming writer from this HTML element.
@param top if true, add a DOCTYPE. See {!to_out_channel}.
@since 0.14 *)letto_writer?top(self:elt):IO.Writer.t=letwrite(oc:#IO.Output.t)=to_output?topselfocinIO.Writer.make~write()(** Convert a HTML element to a stream. This might just convert it to a string
first, do not assume it to be more efficient. *)let[@inline]to_stream(self:elt):IO.Input.t=IO.Input.of_string@@to_stringself