Skip to content

Commit

Permalink
akkoma_autolinks: implement.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Jan 11, 2024
1 parent b9146db commit 5b975cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/parser/autolink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub(crate) fn process_autolinks<'a>(
node: &'a AstNode<'a>,
contents_str: &mut String,
relaxed_autolinks: bool,
akkoma_autolinks: bool,
) {
let contents = contents_str.as_bytes();
let len = contents.len();
Expand Down Expand Up @@ -53,7 +54,7 @@ pub(crate) fn process_autolinks<'a>(
}
}
b'@' => {
post_org = email_match(arena, contents, i);
post_org = email_match(arena, contents, i, akkoma_autolinks);
if post_org.is_some() {
break;
}
Expand Down Expand Up @@ -289,6 +290,7 @@ fn email_match<'a>(
arena: &'a Arena<AstNode<'a>>,
contents: &[u8],
i: usize,
akkoma_autolinks: bool,
) -> Option<(&'a AstNode<'a>, usize, usize)> {
static EMAIL_OK_SET: Lazy<[bool; 256]> = Lazy::new(|| {
let mut sc = [false; 256];
Expand Down Expand Up @@ -325,6 +327,8 @@ fn email_match<'a>(
rewind += 1;
continue;
}
} else if akkoma_autolinks && c == b'@' {
return None;
}

break;
Expand Down
1 change: 1 addition & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,7 @@ impl<'a, 'o, 'c> Parser<'a, 'o, 'c> {
node,
text,
self.options.parse.relaxed_autolinks,
self.options.parse.akkoma_autolinks,
);
}
}
Expand Down

0 comments on commit 5b975cd

Please sign in to comment.