lemaetech / pp_html

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

Home Page:https://lemaetech.co.uk/pp_html/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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>

About

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

https://lemaetech.co.uk/pp_html/

License:Mozilla Public License 2.0


Languages

Language:OCaml 99.4%Language:Makefile 0.6%