Omd_representation
This module does not have a toplevel documentation block.
module R : Map.S
type element = | H1(t) | H2(t) | H3(t) | H4(t) | H5(t) | H6(t) | Paragraph(t) | Text(string) | Emph(t) | Bold(t) | Ul(list(t)) | Ol(list(t)) | Ulp(list(t)) | Olp(list(t)) | Code(name, string) | Code_block(name, string) | Br | Hr | NL | Url(href, t, title) | Ref(ref_container, name, string, fallback) | Img_ref(ref_container, name, alt, fallback) | Html(name, list((string, option(string))), t) | Html_block(name, list((string, option(string))), t) | Html_comment(string) | Raw(string) | Raw_block(string) | Blockquote(t) | Img(alt, src, title) | X( < name : string; to_html : ?indent:int -> (t -> string) -> t -> string option; to_sexpr : (t -> string) -> t -> string option; to_t : t -> t option > )
type fallback = < to_string : string; to_t : t >
type name = string
type alt = string
type src = string
type href = string
type title = string
type tok = | Ampersand | Ampersands(int) | At | Ats(int) | Backquote | Backquotes(int) | Backslash | Backslashs(int) | Bar | Bars(int) | Caret | Carets(int) | Cbrace | Cbraces(int) | Colon | Colons(int) | Comma | Commas(int) | Cparenthesis | Cparenthesiss(int) | Cbracket | Cbrackets(int) | Dollar | Dollars(int) | Dot | Dots(int) | Doublequote | Doublequotes(int) | Exclamation | Exclamations(int) | Equal | Equals(int) | Greaterthan | Greaterthans(int) | Hash | Hashs(int) | Lessthan | Lessthans(int) | Minus | Minuss(int) | Newline | Newlines(int) | Number(string) | Obrace | Obraces(int) | Oparenthesis | Oparenthesiss(int) | Obracket | Obrackets(int) | Percent | Percents(int) | Plus | Pluss(int) | Question | Questions(int) | Quote | Quotes(int) | Semicolon | Semicolons(int) | Slash | Slashs(int) | Space | Spaces(int) | Star | Stars(int) | Tab | Tabs(int) | Tilde | Tildes(int) | Underscore | Underscores(int) | Word(string) | Tag(name, extension)
type extension = < parser_extension : t -> tok list -> tok list -> (t * tok list * tok list) option; to_string : string >
parser_extension
is a method that takes the current state of the parser's data and returns None if nothing has been changed, otherwise it returns the new state. The current state of the parser's data is(r, p, l)
wherer
is the result so far,p
is the list of the previous tokens (it's typically empty or contains information on how many newlines we've just seen), andl
is the remaining tokens to parse.and
to_string
is a method that returns directly a string representation of the object (it's normal if it returns the empty string).
type extensions = list(extension)
One must use this type to extend the parser. It's a list of functions of type extension
. They are processed in order (the head is applied first), so be careful about it. If you use it wrong, it will behave wrong.
let empty_extension: extension
An empty extension
let loose_compare: (t, t) => int
loose_compare t1 t2
returns 0
if t1
and t2
are equivalent, otherwise it returns another number.
let normalise_md: t => t
normalise_md md
returns a copy of md
where some elements have been factorized.
let visit: (element => option(t), t) => t
visitor for structures of type t: visit f md
will return a new potentially altered copy of md
that has been created by the visit of md
by f
.
The function f
takes each element
(from md
) and returns Some t
if it has effectively been applied to element
, and None
otherwise. When it returns Some t
, t
replaces element
in the copy of md
, and when it returns None
, either element
is copied as it is in the copy of md
or a visited version is copied instead (well, that depends on if element
has elements inside of it or not).