package jekyll-format

  1. Overview
  2. Docs
Jekyll post parsing library

Install

Dune Dependency

Authors

Maintainers

Sources

jekyll-format-0.3.1.tbz
sha256=1587cb9f32772e4f22dbc933be0cef9d5aa55e6f666967220b56081f576a1f43
sha512=d3f5991c664ef7729d20ab3ff2ace67da4d8093e90bc17dae33566b15b6711de4f17d26ea067c7de6f7547708ad79e7438b56d22745f44ac1d2828ba6ad9c838

doc/jekyll-format/Jekyll_format/index.html

Module Jekyll_formatSource

Jekyll blog post parsing module

Types and accessors

Sourcetype t

t is a single Jekyll-format post that has been parsed

Sourcetype fields

fields represents the YAML front matter in the blog post

Sourcetype body = string

body represents the blog post content, probably in Markdown format

Sourceval fields : t -> fields

fields t retrieves the YAML front matter fields from the blog post

Sourceval fields_to_yaml : fields -> Yaml.value

fields_to_yaml fs converts fs to a Yaml.value

Sourceval body : t -> body

body t retrieves the blog post content from the blog post

YAML metadata

Sourceval find : string -> fields -> Yaml.value option

find 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.

Sourceval keys : fields -> string list

keys f retrieves all of the key names in the YAML front matter.

Sourceval title : ?fname:string -> fields -> (string, [> Rresult.R.msg ]) Result.result

title ?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.

Sourceval title_exn : ?fname:string -> fields -> string

title_exn ?fname f operates as title except that it raises a Parse_failure exception on error.

Sourceval date : ?fname:string -> fields -> (Ptime.t, [> Rresult.R.msg ]) Result.result

date ?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.

Sourceval date_exn : ?fname:string -> fields -> Ptime.t

date_exn ?fname f operates as date except that it raises a Parse_failure in the error case.

Sourceval slug : ?fname:string -> fields -> (string, [> Rresult.R.msg ]) Result.result

slug ?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.

Sourceval slug_exn : ?fname:string -> fields -> string

slug_exn ?fname f operates as slug except that it raises a Parse_failure in the error case.

Conversion functions

Sourceval of_string : string -> (t, [> Rresult.R.msg ]) result

of_string t parses a Jekyll-format blog post and either returns a t or signals an error in the result.

Sourceval of_string_exn : string -> t

of_string_exn t parses a Jekyll-format blog post and either returns a t or raises a Parse_failure exception with the error string.

Sourceval slug_of_string : string -> string

slug_of_string s replaces all non-ascii characters (a..zA..Z0..9) with the - hyphen character. The result is also lowercase.

Sourceval parse_filename : string -> (Ptime.t * string * string, [> Rresult.R.msg ]) Result.result

parse_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.

Sourceval parse_filename_exn : string -> Ptime.t * string * string

parse_filename_exn f operates as parse_filename except that it raises a Parse_failure in the error case.

Sourceval parse_date : ?and_time:bool -> string -> (Ptime.t, [> Rresult.R.msg ]) Result.result

parse_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.

Sourceval parse_date_exn : ?and_time:bool -> string -> Ptime.t

parse_date_exn ?and_time s operates as parse_date except that it raises a Parse_failure in the error case.

Sourceexception Parse_failure of string

Exception raised on parse failure by the _exn functions in this module. The argument is a human-readable error message.

Pretty printers

Sourceval pp : t Fmt.t

pp t prints out the blog post and YAML front matter, using pp_fields and pp_body respectively.

Sourceval pp_body : body Fmt.t

pp_body body prints out the blog post body in the original layout.

Sourceval pp_fields : fields Fmt.t

pp_fields f prints out the YAML front matter in the original layout.

OCaml

Innovation. Community. Security.