Page
Library
Module
Module type
Parameter
Class
Class type
Source
OmdSourceA 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.
and ref_container =
< add_ref : string -> string -> string -> unit
; get_ref : string -> (string * string) option
; get_all : (string * (string * string)) list >and element = Omd_representation.element = | H1 of tHeader of level 1
*)| H2 of tHeader of level 2
*)| H3 of tHeader of level 3
*)| H4 of tHeader of level 4
*)| H5 of tHeader of level 5
*)| H6 of tHeader of level 6
*)| Paragraph of t| Text of stringText.
*)| Emph of tEmphasis (italic)
*)| Bold of tBold
*)| Ul of t listUnumbered list
*)| Ol of t listOrdered (i.e. numbered) list
*)| Ulp of t list| Olp of t list| Code of name * stringCode(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 of name * stringCode_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
*)| HrHorizontal rule
*)| NLNewline character. Newline characters that act like delimiters (e.g. for paragraphs) are removed from the AST.
*)| Url of href * t * title| Ref of ref_container * name * string * fallback| Img_ref of ref_container * name * alt * fallback| Html of name * (string * string option) list * t| Html_block of name * (string * string option) list * t| Html_comment of stringAn HTML comment, including "<!--" and "-->".
*)| Raw of stringRaw: something that shall never be converted
*)| Raw_block of stringRaw_block: a block with contents that shall never be converted
*)| Blockquote of tQuoted block
*)| Img of alt * src * title| X of < name : string
; to_html : ?indent:int -> (t -> string) -> t -> string option
; to_sexpr : (t -> string) -> t -> string option
; to_t : t -> t option >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.
val of_string :
?extensions:Omd_representation.extensions ->
?default_lang:name ->
string ->
tof_string s returns the Markdown representation of the string s.
If you want to use a custom lexer or parser, use Omd_lexer.lex and Omd_parser.parse.
val of_bigarray :
?extensions:Omd_representation.extensions ->
?default_lang:name ->
Omd_lexer.bigstring ->
tAs of_string, but read input from a bigarray rather than from a string.
set_default_lang lang md return a copy of md where the language of all Code or Code_block with an empty language is set to lang.
val to_html :
?override:(Omd_representation.element -> string option) ->
?pindent:bool ->
?nl2br:bool ->
?cs:code_stylist ->
t ->
stringTranslate 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.