NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Basic Link Parsing In Rust's nom Crate

This is the start of the code I'm using to parse out links for Neopolitan. Next up is to send info about the type along with the code that gets returned to allow for further processing.

March 2023
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::bytes::complete::take_until;
use nom::combinator::eof;
use nom::combinator::rest;
use nom::multi::many_till;
use nom::sequence::delimited;
use nom::IResult;

fn main() {
    let source = r#"some <<link|example|https://www.example.com/>> link"#;
    let (_, parts) = parse(source).unwrap();

fn parse(source: &str) -> IResult<&str, Vec<String>> {
    let (source, texts) = many_till(get_parts, eof)(source)?;
    Ok((source, texts.0))

fn get_parts(source: &str) -> IResult<&str, String> {
    let (source, value) = alt((
        delimited(tag("<<"), take_until(">>"), tag(">>")),
    Ok((source, value.to_string()))
[TODO: Result]
═══ § ═══