package yocaml_cmarkit

  1. Overview
  2. Docs
On This Page
  1. API
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Yocaml_cmarkitSource

Describing documents using a Markup language is very common in the Blogosphere (rather than describing all the formatting of document content in HTML, using <p>, <strong> and co).

Common Mark is a specification (see RFC7763/RFC7764) of Markdown since 2016. As it is a very popular markup language, OCaml has several very good libraries for turning Common Mark into HTML. This library is a wrapper around cmarkit, an excellent Common Mark conversion library.

API

Sourceval to_html : ?strict:bool -> ?safe:bool -> unit -> (string, string) Yocaml.Task.t

to_html ~strict ~safe () is an arrow that produces an HTML (as a String) from a String in Common Mark.

The strict argument permits to follow only the Common Mark specification. If you attempt to use some extensions (see Cmarkit.Doc.of_string), you should set it to false.

The safe argument ensures that any HTML code written in your Common Mark document is escaped as an HTML comment. As most of the time, the markdown provided comes from the user, this functionnality is disabled by default. If you want to activate this feature, you should set it to true.

Sourceval to_html_with_toc : ?strict:bool -> ?safe:bool -> unit -> (string, string option * string) Yocaml.Task.t

Same as to_html but it returns a pair where the first argument is an HTML representation of the table of contents, and the second one is the document.

Sourceval content_to_html : ?strict:bool -> ?safe:bool -> unit -> ('a * string, 'a * string) Yocaml.Task.t

Since it is pretty common to deal with document and Metadata, which are generally a pair of Metadata and the content of the document, content_to_html is a function that produce an arrow which apply the Common Mark conversion on the second element (the content).

content_to_html () is equivalent of Yocaml.Task.second to_html.

Sourceval content_to_html_with_toc : ?strict:bool -> ?safe:bool -> ('a -> string option -> 'b) -> ('a * string, 'b * string) Yocaml.Task.t

Same as content_to_html but it returns a pair where the first argument is an HTML representation of the table of contents, and the second one is the document. The arrow takes also a f that can merge the metadata with the computed table of contents.

Sourceval to_doc : ?strict:bool -> unit -> (string, Cmarkit.Doc.t) Yocaml.Task.t

Intermerdiate arrow that build the document.

Sourceval table_of_contents : (Cmarkit.Doc.t, string option * Cmarkit.Doc.t) Yocaml.Task.t

Compute the table of contents from a doc.

Sourceval from_doc_to_html : ?safe:bool -> unit -> (Cmarkit.Doc.t, string) Yocaml.Task.t

Intermerdiate arrow that convert a document to html.

Sourceval extract_toc : Cmarkit.Doc.t -> string option

Compute a table of content from a given document.

OCaml

Innovation. Community. Security.