# Table of Contents <!-- omit in toc -->
- [Overview](#overview)
- [Versioning](#versioning)
- [Configuration](#configuration)
- [Example](#example)
# Overview
A library that allows a user to extract an arbitrary number of lines of "frontmatter" from the start of any multiline string.
Included is some basic auto-detection of what lines are considered to be part of the frontmatter, but erroneous detection can be prevented by tuning the configuration.
Note that absolutely no parsing of extracted frontmatter is performed; this is designed to output its results for another library to then parse.
## Versioning
This project follows [Semantic Versioning principals](https://semver.org/) starting with `v1.0.0`
# Configuration
| `number` | `Option<usize>` | The exact number of lines to extract, ignoring `end_line`; omit for auto-detection based on `end_line` or consecutive lines of `lead_chars` |
| `end_line` | `Option<&str>` | Treat the first occurrence of this string (alone on a line except for `lead_chars`) as the end of frontmatter |
| `lead_chars` | `Option<&str>` | Strip this string from the start of extracted frontmatter lines; consecutive lines starting with this string are treated as frontmatter lines if `number` and `end_line` are not specified |
| `discard_first` | `bool` | Whether or not to discard the entire first line that is extracted |
## Example
Given a variable `input` with the following text:
```md
# Title
This is an example markdown document.
```
... and the following code:
```rust
use extract_frontmatter::{Config, extract};
let config = Config::new(None, Some("-->"), None, true);
let output = extract(&config, input);
```
... the variable `output` will contain:
```yml
parent:
- item1
- item2
```