package omd

  1. Overview
  2. Docs
module R : sig ... end
class ref_container : object ... end
type element =
  1. | H1 of t
  2. | H2 of t
  3. | H3 of t
  4. | H4 of t
  5. | H5 of t
  6. | H6 of t
  7. | Paragraph of t
  8. | Text of string
  9. | Emph of t
  10. | Bold of t
  11. | Ul of t list
  12. | Ol of t list
  13. | Ulp of t list
  14. | Olp of t list
  15. | Code of name * string
  16. | Code_block of name * string
  17. | Br
  18. | Hr
  19. | NL
  20. | Url of href * t * title
  21. | Ref of ref_container * name * string * fallback
  22. | Img_ref of ref_container * name * alt * fallback
  23. | Html of name * (string * string option) list * t
  24. | Html_block of name * (string * string option) list * t
  25. | Html_comment of string
  26. | Raw of string
  27. | Raw_block of string
  28. | Blockquote of t
  29. | Img of alt * src * title
  30. | 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 >
and fallback = < to_string : string ; to_t : t >
and name = string
and alt = string
and src = string
and href = string
and title = string
and t = element list
type tok =
  1. | Ampersand
  2. | Ampersands of int
  3. | At
  4. | Ats of int
  5. | Backquote
  6. | Backquotes of int
  7. | Backslash
  8. | Backslashs of int
  9. | Bar
  10. | Bars of int
  11. | Caret
  12. | Carets of int
  13. | Cbrace
  14. | Cbraces of int
  15. | Colon
  16. | Colons of int
  17. | Comma
  18. | Commas of int
  19. | Cparenthesis
  20. | Cparenthesiss of int
  21. | Cbracket
  22. | Cbrackets of int
  23. | Dollar
  24. | Dollars of int
  25. | Dot
  26. | Dots of int
  27. | Doublequote
  28. | Doublequotes of int
  29. | Exclamation
  30. | Exclamations of int
  31. | Equal
  32. | Equals of int
  33. | Greaterthan
  34. | Greaterthans of int
  35. | Hash
  36. | Hashs of int
  37. | Lessthan
  38. | Lessthans of int
  39. | Minus
  40. | Minuss of int
  41. | Newline
  42. | Newlines of int
  43. | Number of string
  44. | Obrace
  45. | Obraces of int
  46. | Oparenthesis
  47. | Oparenthesiss of int
  48. | Obracket
  49. | Obrackets of int
  50. | Percent
  51. | Percents of int
  52. | Plus
  53. | Pluss of int
  54. | Question
  55. | Questions of int
  56. | Quote
  57. | Quotes of int
  58. | Semicolon
  59. | Semicolons of int
  60. | Slash
  61. | Slashs of int
  62. | Space
  63. | Spaces of int
  64. | Star
  65. | Stars of int
  66. | Tab
  67. | Tabs of int
  68. | Tilde
  69. | Tildes of int
  70. | Underscore
  71. | Underscores of int
  72. | Word of string
  73. | Tag of name * extension
    (*

    Lexer's tokens. If you want to use the parser with an extended lexer, you may use the constructor Tag to implement the parser's extension. In the parser, Tag is used (at least) 3 times in order to represent metadata or to store data.

    The integers carried by constructors means that the represented character appears (n+2) times. So, Ampersand(0) is "&&". Notably, this allows to use the property that in the match case Ampersand _ ->, we know there are at least 2 ampersands. This is particularly useful for some characters, such as newlines and spaces. It's not useful for all of them indeed but it has been designed this way for the sake of uniformity (one doesn't want to know by heart which constructor have that "at least 2" property and which haven't).

    *)
and 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) where r 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), and l 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 = extension list

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.

val empty_extension : extension

An empty extension

val loose_compare : t -> t -> int

loose_compare t1 t2 returns 0 if t1 and t2 are equivalent, otherwise it returns another number.

val normalise_md : t -> t

normalise_md md returns a copy of md where some elements have been factorized.

val visit : (element -> t option) -> 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).

OCaml

Innovation. Community. Security.