Types and accessors
type body = Astring.String.Sub.tbody represents the blog post content, probably in Markdown format
YAML metadata
val find : string -> fields -> string optionfind key t retrieves the first key from the YAML front matter, and None if the key is not present. Keys are case-sensitive as per the YAML specification. Whitespace is trimmed around the field value.
val keys : fields -> string listkeys f retrieves all of the key names in the YAML front matter.
val title : ?fname:string -> fields -> (string, [> Rresult.R.msg ]) Result.resulttitle ?fname f will query the title from the YAML metadata, and fallback to parsing the optional fname filename of the post if no explicit key is found. If nothing works then None is returned.
val title_exn : ?fname:string -> fields -> stringtitle_exn ?fname f operates as title except that it raises a Parse_failure exception on error.
val date : ?fname:string -> fields -> (Ptime.t, [> Rresult.R.msg ]) Result.resultdate ?fname f will query the post date from the YAML metadata, and fallback to parsing the optional fname filename of the post if no explicit key is found.
date_exn ?fname f operates as date except that it raises a Parse_failure in the error case.
val slug : ?fname:string -> fields -> (string, [> Rresult.R.msg ]) Result.resultslug ?fname f will query the slug name from the YAML metadata, or calculate it from the filename if no explicit slug field is set, and finally fallback to parsing the title of the post if nothing else is found. The slug is calculated using slug_of_string.
val slug_exn : ?fname:string -> fields -> stringslug_exn ?fname f operates as slug except that it raises a Parse_failure in the error case.
Conversion functions
val of_string : string -> (t, [> Rresult.R.msg ]) Result.resultof_string t parses a Jekyll-format blog post and either returns a t or signals an error in the result.
val of_string_exn : string -> tof_string_exn t parses a Jekyll-format blog post and either returns a t or raises a Parse_failure exception with the error string.
val body_to_string : body -> stringbody_to_string body serialises the body to an OCaml string, maintaining the original layout and whitespace.
slug_of_string s replaces all non-ascii characters (a..zA..Z0..9) with the - hyphen character. The result is also lowercase.
val parse_filename : string -> (Ptime.t * string * string, [> Rresult.R.msg ]) Result.resultparse_filename f parses a Jekyll format filename YEAR-MONTH-DAY-title.MARKUP and returns the time, title and markup components respectively. If the time could not be parsed, then the header is assumed to be the title and None is returned for the time.
val parse_filename_exn : string -> Ptime.t * string * stringparse_filename_exn f operates as parse_filename except that it raises a Parse_failure in the error case.
val parse_date : ?and_time:bool -> string -> (Ptime.t, [> Rresult.R.msg ]) Result.resultparse_date ?and_time s parses a Jekyll format date field in YYYY-MM-DD HH:MM:SS +/-TT:TT format, where the HMS and timezone components are optional. and_time defaults to true and causes the non-date components to be parsed; setting it to false only causes the YMD portions to be parsed.
val parse_date_exn : ?and_time:bool -> string -> Ptime.tparse_date_exn ?and_time s operates as parse_date except that it raises a Parse_failure in the error case.
Exception raised on parse failure by the _exn functions in this module. The argument is a human-readable error message.
Pretty printers
Error strings
module E : sig ... endThese are error strings returned by the parser. They are primarily used by the test cases to pattern match on failures and are not for general use.