home ~ socials ~ projects ~ rss

Remove Lines That Start With A Token In Rust

July 2023

TODO: Write this up from the org mode to noepolitan processor.

pub fn body(source: &str) -> IResult<&str, &str> {
    let (source, lines) = many_till(
        alt((
            preceded(
                many0(tuple((tag("#+"), not_line_ending, line_ending))),
                terminated(not_line_ending, line_ending),
            ),
            multispace1.map(|x| "\n"),
            not_line_ending,
            line_ending,
        )),
        eof,
    )(source)?;

    ///// etc...
}
end of line
Share link:
https://www.alanwsmith.com/en/2s/et/le/iy/?remove-lines-that-start-with-a-token-in-rust