diff --git a/src/omd.ml b/src/omd.ml index 6104ad75..50b579b6 100644 --- a/src/omd.ml +++ b/src/omd.ml @@ -14,6 +14,26 @@ let parse_inlines (md, defs) = in List.map (Mapper.map (parse_inline defs)) md +let txt ?(attrs = []) s = Text (attrs, s) +let em ?(attrs = []) il = Emph (attrs, il) +let strong ?(attrs = []) il = Strong (attrs, il) +let code ?(attrs = []) s = Code (attrs, s) +let br = Hard_break [] +let nl = Soft_break [] +let a ?(attrs = []) li = Link (attrs, li) +let img ?(attrs = []) li = Image (attrs, li) +let html ?(attrs = []) s = Html (attrs, s) +let p ?(attrs = []) il = Paragraph (attrs, il) +let ul ?(attrs = []) ?(spacing = Loose) l = List (attrs, Bullet '-', spacing, l) + +let ol ?(attrs = []) ?(spacing = Loose) l = + List (attrs, Ordered (1, '.'), spacing, l) + +let blockquote ?(attrs = []) blocks = Blockquote (attrs, blocks) +let hr = Thematic_break [] +let code_bl ?(attrs = []) ~label s = Code_block (attrs, label, s) +let html_bl ?(attrs = []) s = Html_block (attrs, s) +let dl ?(attrs = []) l = Definition_list (attrs, l) let of_channel ic = parse_inlines (Pre.of_channel ic) let of_string s = parse_inlines (Pre.of_string s) let to_html doc = Html.to_string (Html.of_doc doc) diff --git a/src/omd.mli b/src/omd.mli index f0b3f6ee..134c1640 100644 --- a/src/omd.mli +++ b/src/omd.mli @@ -46,6 +46,34 @@ type 'attr block = type doc = attributes block list (** A markdown document *) +val txt : ?attrs:attributes -> string -> attributes inline +val em : ?attrs:attributes -> attributes inline -> attributes inline +val strong : ?attrs:attributes -> attributes inline -> attributes inline +val code : ?attrs:attributes -> string -> attributes inline +val br : attributes inline +val nl : attributes inline +val a : ?attrs:attributes -> attributes link -> attributes inline +val img : ?attrs:attributes -> attributes link -> attributes inline +val html : ?attrs:attributes -> string -> attributes inline +val p : ?attrs:attributes -> attributes inline -> attributes block + +val ul : + ?attrs:attributes + -> ?spacing:list_spacing + -> attributes block list list + -> attributes block + +val ol : + ?attrs:attributes + -> ?spacing:list_spacing + -> attributes block list list + -> attributes block + +val blockquote : ?attrs:attributes -> attributes block list -> attributes block +val hr : attributes block +val code_bl : ?attrs:attributes -> label:string -> string -> attributes block +val html_bl : ?attrs:attributes -> string -> attributes block +val dl : ?attrs:attributes -> attributes def_elt list -> attributes block val of_channel : in_channel -> doc val of_string : string -> doc val to_html : doc -> string