fml 0.6.2

Friendly Markup Language
Documentation
use crate::{
    ast::*,
    parser::{
        Stream,
        functions::{macros::*, styles::*},
    },
};
use winnow::{
    Result,
    ascii::*,
    combinator::{repeat, *},
    error::{ContextError, ParserError, StrContext},
    prelude::*,
    token::*,
};

pub fn headings<'i>(input: &mut Stream<'i>) -> Result<FmlValue> {
    alt((heading_1, heading_2, heading_3)).parse_next(input)
}

macro_rules! head {
    ($parser:expr, $map:expr, $input:expr) => {{
        let scope: String = llp!($parser).parse_next($input)?;
        let mut state = $input.state.clone();
        state.is_in_heading = true;
        inner_fml(&scope, state).map($map)
    }};
}

fn heading_1<'i>(input: &mut Stream<'i>) -> Result<FmlValue> {
    head!("#", FmlValue::Heading1, input)
}
fn heading_2<'i>(input: &mut Stream<'i>) -> Result<FmlValue> {
    head!("##", FmlValue::Heading2, input)
}
fn heading_3<'i>(input: &mut Stream<'i>) -> Result<FmlValue> {
    head!("###", FmlValue::Heading3, input)
}