module Markdown:sig
..end
Structured representation of Markdown content.
type
align =
| |
Left |
| |
Center |
| |
Right |
Table columns alignment
type
href =
| |
URL of |
(* | URL href is printed as it is. | *) |
| |
Page of |
(* | URL relative to a common root.
During pretty-printing, if given the path of the current
document, the string will be modified accordingly. For instance,
when writing to | *) |
| |
Section of |
(* | URL of an anchor within a | *) |
Local refs and URLs
type
inline =
| |
Plain of |
(* | Printed as it is | *) |
| |
Emph of |
(* | Printed as | *) |
| |
Bold of |
(* | Printed as | *) |
| |
Inline_code of |
(* | Printed as | *) |
| |
Link of |
(* | Hyperlink with text and URL | *) |
| |
Image of |
(* |
| *) |
typetext =
inline list
Inline elements separated by spaces
type
block_element =
| |
Text of |
(* | Single paragraph of text. | *) |
| |
Block_quote of |
|||
| |
UL of |
|||
| |
OL of |
|||
| |
DL of |
(* | definition list | *) |
| |
EL of |
(* | example list | *) |
| |
Code_block of |
typeblock =
block_element list
type
table = {
|
caption : |
|
header : |
|
content : |
type
element =
| |
Comment of |
(* | markdown comment, printed <!-- like this --> | *) |
| |
Block of |
|||
| |
Table of |
|||
| |
Raw of |
(* | Each element of the list is printed as-is on its own line.
A blank line separates the | *) |
| |
H1 of |
|||
| |
H2 of |
|||
| |
H3 of |
|||
| |
H4 of |
|||
| |
H5 of |
|||
| |
H6 of |
typeelements =
element list
type
pandoc_markdown = {
|
title : |
|
: |
|
date : |
|
elements : |
Remark: text
values are list of inline
values, hence
you may combined with the (@)
operator or with the glue ?sep
utility
function (see below).
val plain : string -> text
Plain markdown
val emph : string -> text
Emph text
val bold : string -> text
Bold text
val code : string -> text
Inline code
val image : alt:string -> file:string -> text
Image
val href : ?text:text -> href -> text
Href link
val link : ?text:text -> ?page:string -> ?name:string -> unit -> text
Local links
val url : ?text:text -> string -> text
URL links
val format : ('a, Stdlib.Format.formatter, unit, text) Stdlib.format4 -> 'a
Plain markdown content of the formatted string
Remark: block
values are list of block_element
values, hence
you may combined with the (@)
operator or with the glue ?sep
utility
function (see below).
val text : text -> block
Text Block
val list : block list -> block
Itemized list
val enum : block list -> block
Enumerated list
val description : (text * text) list -> block
Description list
val codeblock : ?lang:string ->
('a, Stdlib.Format.formatter, unit, block) Stdlib.format4 -> 'a
codeblock lang "...."
returns a Code_block
for code
,
written in lang
with the given formatted content.
The code block content placed inside an englobing hv-box, trimed
and finally splitted into lines.
Remark: elements
values are list of element
values, hence
you may combined with the (@)
operator or with the glue ?sep
utility
function (see below).
val par : text -> elements
Single Paragraph element
val quote : text -> elements
Quoted Paragraph element
val block : block -> elements
Block element
val table : table -> elements
Table element
val rawfile : string -> elements
Get the content of a file as raw markdown.
Sys_error
if there's no such file.val pandoc : ?title:text ->
?authors:text list ->
?date:text -> elements -> pandoc_markdown
Creates a document from a list of elements and optional metadatas. Defaults are:
val section : ?name:string -> title:string -> elements -> elements
Adds a H1
header with the given title
on top of the given elements.
If name is not explicitly provided,
the header will have as associated anchor id title
val subsections : elements -> elements list -> elements
subsections header body
returns a list of element
s where the body
's
headers have been increased by one (i.e. H1
becomes H2
).
H5
stays at H5
, though.
val glue : ?sep:'a list -> 'a list list -> 'a list
Glue fragments, typically used for combining text
, block
and elements
.
Default separator is empty. The function is tail-recursive.
val label : string -> string
Transforms a string into an anchor name, roughly following pandoc's conventions. This function is automatically used by pretty-printers and smart constructors to normalize section names and local links.
val pp_inline : ?page:string -> Stdlib.Format.formatter -> inline -> unit
val pp_text : ?page:string -> Stdlib.Format.formatter -> text -> unit
val pp_block_element : ?page:string -> Stdlib.Format.formatter -> block_element -> unit
val pp_block : ?page:string -> Stdlib.Format.formatter -> block -> unit
val pp_element : ?page:string -> Stdlib.Format.formatter -> element -> unit
val pp_elements : ?page:string -> Stdlib.Format.formatter -> elements -> unit
val pp_pandoc : ?page:string -> Stdlib.Format.formatter -> pandoc_markdown -> unit