Module Polebrush_html


module Polebrush_html: sig .. end
Facilities for converting polebrush into html


This module uses type Enum.t from ExtLib as a more powerful way to work with streams.
exception Invalid_polebrush of string
Raises only when function receives invalid AST, for example, with Header 10.
type toc = (string * int * Polebrush.line list) list 
Type of Table of Contents, where each line is a tuple of header's id, header's level and header itself
val toc_of_enum : Polebrush.block Enum.t -> toc * Polebrush.block Enum.t
Consumes the enumeration and returns a Table of Contents and enumeration with additionaly id's in headers
val elements_of_toc : toc -> Polebrush.element list
val of_enum : ?disable_toc:bool ->
?escape_cdata:bool ->
?escape_nomarkup:bool ->
?code_highlight_cmd:string -> Polebrush.block Enum.t -> string Enum.t
disable_toc : Do not generate Tables of Contents. Accelerates outputing and makes it streaming. If true, all Polebrush.ToC will be ignored. Default if false.
escape_cdata : Do not escape spedial HTML chars. Default is false.
escape_nomarkup : Escape special HTML chars even in ==nomarkup== and nomarkup.. Default is false.
val of_stream : ?escape_cdata:bool ->
?escape_nomarkup:bool ->
?code_highlight_cmd:string -> Polebrush.block Stream.t -> string Stream.t
The same, but do stream processing and don't do tables of Contents, just ignore it.
escape_cdata : Do not escape spedial HTML chars. Default is false.
escape_nomarkup : Escape special HTML chars even in ==nomarkup== and nomarkup.. Default is false.
val of_block : ?toc:toc ->
?escape_cdata:bool ->
?escape_nomarkup:bool ->
?code_highlight_cmd:string -> Polebrush.block -> string
The same, but takes only one polebrush block.
toc : Table of Contents which will be used if toc. will attended. If not passed, all toc. will be ignored.
escape_cdata : Do not escape spedial HTML chars. Default is false.
escape_nomarkup : Escape special HTML chars even in ==nomarkup== and nomarkup.. Default is false.

Example of use:

let () =
  let to_lines path =
    let chan = open_in path in
    Stream.from
      (fun _ ->
        try Some (input_line chan)
        with End_of_file -> Nonein
  let lines = to_lines "test.txt" in
  let polebrush = Polebrush_pasrer.of_stream lines in
  Stream.iter print_endline (Polebrush_html.of_block polebrush)

val of_line : ?escape_cdata:bool -> ?escape_nomarkup:bool -> Polebrush.line -> string