/pp_html

[Unreleased] Ocaml library to pretty print/format HTML5. See notes in README.

Primary LanguageOCamlMozilla Public License 2.0MPL-2.0

Pretty-printer, formatter for HTML5 (Unreleased and not production ready)

Note - The parser hasn't been validated against HTML5 RFC.

Example

let () =
  let html = 
    {|<!DOCTYPE html><html><body><br> 
    <hr class="class1" id="id1"/>
    <!-- This is a comment --> 
     <div class="class1"     id ='id1' style="align: center" enabled>Hello World!</div>
     <div></div>
     <div disabled id   =   hello id = 
      hello2 id3 = 
       hello3></div>
    </body></html>|} in 
  Pp_html.parse html
  |> Pp_html.pp ~indent:4 Format.std_formatter
;;

The above code produces the following formatted HTML5.

<!DOCTYPE html>

<html>
    <body>
        <br />
        <hr class="class1"
            id="id1"/>

        <!--  This is a comment  -->
        <div class="class1"
             id="id1"
             style="align: center"
             enabled>
            Hello World!
        </div>
        <div>
        </div>
        <div disabled
             id="hello"
             id="hello2"
             id3="hello3">
        </div>
    </body>
</html>