[ANN] Frontmatter_extractor.0.1

Hi there! :waving_hand:

I am writing again about my new library, which I must create, because there is simply no alternative available.

Frontmatter_extractor is a small library that extracts the front matter section of a text file. It is commonly used in static content generators (blog engines, etc), such as those that convert Markdown files into HTML or other formats.

Example of usage

let some_text = {|
---
title: "My First Blog Post"
date: 2025-12-1
---

Hello! It's just some text...
|};;

Extract frontmatter as plain text.

# Frontmatter_extractor.of_string some_text;;

- : Frontmatter_extractor.extracted =
{Frontmatter_extractor.matter =
  Some "\ntitle: \"My First Blog Post\"\ndate: 2025-12-1\n";
 body = "\n\nHello! It's just some text...\n"}

Extract the front matter as parsed YAML values. The yaml library needs to be installed.

# Frontmatter_extractor_yaml.of_string_exn some_text;;

- : Frontmatter_extractor_yaml.extracted =
{Frontmatter_extractor_yaml.attrs =
  Some
   (`O [("title", `String "My First Blog Post"); ("date", `String "2025-12-1")]);
 body = "\n\nHello! It's just some text...\n"}

P.S.

It’s not fully tested, but it’s usable as a first version.

1 Like