header-config 0.1.7

Runtime parser for hierarchical configurations using Markdown-style headers
Documentation
# Header Config Parser

[![Crates.io](https://img.shields.io/crates/v/header-config)](https://crates.io/crates/header-config)
[![Docs.rs](https://docs.rs/header-config/badge.svg)](https://docs.rs/header-config)
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)](LICENSE)

A Rust library for parsing hierarchical configuration files using Markdown-style headers, transforming nested sections into flat key-value pairs with namespaced keys.

## Features

- ๐Ÿ“‚ Header-based namespacing
- โž• Automatic key hierarchy flattening
- ๐Ÿงน Whitespace-tolerant parsing
- ๐Ÿšฆ Empty value handling
- ๐Ÿ” Simple string-based lookups

## Installation

Add to your `Cargo.toml`:
```toml
[dependencies]
header-config = "0.1"
```

## Usage

```rust
use header_config::{parse_config, parse_config_str};

let from_file = parse_config(std::path::Path::new("config.md"))?;
let from_text = parse_config_str("# Section\n\nkey value\n")?;
```

Both return an `IndexMap<Box<str>, Box<str>>` of namespaced keys; `parse_config_str` parses an in-memory string (for example a section embedded in a larger file or a network response).

## File Format Specification

### Basic Syntax
```
# Server Config

port 8080
timeout 30

# Database

host localhost
user admin

## Replica

host replica.db
```

### Key Features

- **Headers** create namespaces using `#` symbols
- **Keys** are whitespace-separated from values
- **Empty values** allowed (`key` without value)
- **Nesting** with subheaders (`## Subsection`)

### Parsing Rules

- Header levels determine namespace depth
- It's not allowed to go more than one header level deeper at once
- Keys inherit all parent header namespaces
- Case-sensitive matching
- Duplicates aren't allowed

## Example

The format looks like this:

```
key1 value
key2

# HeaderA

key1 value
key2

# HeaderB

key1 value
key2

## SubheaderA

key1 value
key2

## SubheaderB

key1 value
key2
```

The created mapping will be something like this:

```
"key1" -> "value"
"key2" -> ""
"HeaderA:key1" -> "value"
"HeaderA:key2" -> ""
"HeaderB:key1" -> "value"
"HeaderB:key2" -> ""
"HeaderB:SubheaderA:key1" -> "value"
"HeaderB:SubheaderA:key2" -> ""
"HeaderB:SubheaderB:key1" -> "value"
"HeaderB:SubheaderB:key2" -> ""
```