From 55d358c82d6160ff3812f2748dbac609edaef608 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Wed, 10 Jan 2024 21:07:56 +0330 Subject: [PATCH] starting to work with #16 --- src/parser/parse_from_text/link_element.rs | 27 +++++++++++++++++++++ src/parser/parse_from_text/text_elements.rs | 5 ++++ 2 files changed, 32 insertions(+) create mode 100644 src/parser/parse_from_text/link_element.rs diff --git a/src/parser/parse_from_text/link_element.rs b/src/parser/parse_from_text/link_element.rs new file mode 100644 index 0000000..6ab5853 --- /dev/null +++ b/src/parser/parse_from_text/link_element.rs @@ -0,0 +1,27 @@ +use crate::parser::link_url::LinkDestination; +use super::Element; +use crate::nom::{Offset, Slice}; +use nom::bytes::complete::take_while; +use nom::character::complete::char; +use nom::{ + bytes::{ + complete::{tag, take, take_while1}, + streaming::take_till1, + }, + character, + combinator::{peek, recognize, verify}, + sequence::tuple, + AsChar, IResult, +}; +use super::base_parsers::*; + +// Link syntax here is according to RFC 3986 & 3987 --Farooq + + +fn is_alpha(c: char) -> bool { + let c = c as u64; + // basically in inclusive ranges of [0x40, 0x5a] OR + // [0x61, 0x7a] + // TODO: order the conditions for better performance + c >= 0x41 && c <= 0x7a && c <= 0x5a && c >= 0x61 +} diff --git a/src/parser/parse_from_text/text_elements.rs b/src/parser/parse_from_text/text_elements.rs index 6914cd6..476ea31 100644 --- a/src/parser/parse_from_text/text_elements.rs +++ b/src/parser/parse_from_text/text_elements.rs @@ -98,6 +98,11 @@ fn not_link_part_char(c: char) -> bool { !matches!(c, ':' | '\n' | '\r' | '\t' | ' ') } + +fn link(input: &str) -> IResult<&str, (), CustomError<&str>> { + let (input, _) = take_while1(link_scheme)(input)?; +} + /// rough recognition of an link, results gets checked by a real link parser fn link_intern(input: &str) -> IResult<&str, (), CustomError<&str>> { let (input, _) = take_while1(not_link_part_char)(input)?;