Skip to content

Commit

Permalink
starting to work with #16
Browse files Browse the repository at this point in the history
  • Loading branch information
farooqkz committed Jan 10, 2024
1 parent a1db594 commit 55d358c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/parser/parse_from_text/link_element.rs
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 5 additions & 0 deletions src/parser/parse_from_text/text_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 55d358c

Please sign in to comment.