A markdown parser in OCaml, with no extra dependencies.
This module represents this entire Markdown library written in OCaml only.
Its main purpose is to allow you to use the Markdown library while keeping you away from the other modules.
If you want to extend the Markdown parser, you can do it without accessing any module of this library but this one, and by doing so, you are free from having to maintain a fork of this library.
N.B. This module is supposed to be reentrant, if it's not then please report the bug.
(* | Header of level 1 | *) | |
(* | Header of level 2 | *) | |
(* | Header of level 3 | *) | |
(* | Header of level 4 | *) | |
(* | Header of level 5 | *) | |
(* | Header of level 6 | *) | |
(* | A Markdown paragraph (must be enabled in of_string) | *) | |
#
| Text of string
| (* | Text. | *) |
(* | Emphasis (italic) | *) | |
(* | Bold | *) | |
(* | Unumbered list | *) | |
(* | Ordered (i.e. numbered) list | *) | |
(* | Code(lang, code) represent code within the text (Markdown:
`code`). The language lang cannot be specified from Markdown,
it can be from of_string though or when programatically
generating Markdown documents. Beware that the code is taken
verbatim from Markdown and may contain characters that must be
escaped for HTML. | *) | |
(* | Code_block(lang, code) : a code clock (e.g. indented by 4
spaces in the text). The first parameter lang is the language
if specified. Beware that the code is taken verbatim from
Markdown and may contain characters that must be escaped for
HTML. | *) | |
#
| Br
| (* | (Forced) line break | *) |
#
| Hr
| (* | Horizontal rule | *) |
#
| NL
| (* | Newline character. Newline characters that act like delimiters (e.g. for paragraphs) are removed from the AST. | *) |
#
| Html_comment of string
| (* | An HTML comment, including "<!--" and "-->". | *) |
#
| Raw of string
| (* | Raw: something that shall never be converted | *) |
#
| Raw_block of string
| (* | Raw_block: a block with contents that shall never be converted | *) |
(* | Quoted block | *) | |
A element of a Markdown document.
Fallback for references in case they refer to non-existant references
Markdown reference name.
HTML img tag attribute.
HTML attribute.
HTML attribute.
HTML attribute.
Function that takes a language name and some code and returns that code with style.
of_string s
returns the Markdown representation of the string
s
.
""
.As of_string, but read input from a bigarray rather than from a string.
Translate markdown representation into raw HTML. If you need a
full HTML representation, you mainly have to figure out how to
convert Html of string
and Html_block of string
into your HTML representation.
toc md
returns toc
a table of contents for md
.
~start:[2;3]
will build the TOC for subsections of
the second H1
header, and within that section, the third h2
header. If a number is 0
, it means to look for the first
section at that level but stop if one encounters any other
subsection. If no subsection exists, an empty TOC []
will be
returned. Default: []
i.e. list all sections, starting with the
first H1
.
2
.