From 99a6e19cfcc5ea44a919b2b13cff8b9e3fadc910 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Wed, 8 Sep 2021 16:56:17 +0200 Subject: [PATCH] feat(january): ignore links between angle brackets --- src/database/entities/microservice/january.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/database/entities/microservice/january.rs b/src/database/entities/microservice/january.rs index 39df9ef0..97ffaf62 100644 --- a/src/database/entities/microservice/january.rs +++ b/src/database/entities/microservice/january.rs @@ -100,11 +100,15 @@ impl Embed { pub async fn generate(content: String) -> Result> { lazy_static! { static ref RE_CODE: Regex = Regex::new("```(?:.|\n)+?```|`(?:.|\n)+?`").unwrap(); + static ref RE_IGNORED: Regex = Regex::new("()").unwrap(); } // Ignore code blocks. let content = RE_CODE.replace_all(&content, ""); + // Ignore all content between angle brackets starting with http. + let content = RE_IGNORED.replace_all(&content, ""); + let content = content // Ignore quoted lines. .split("\n") @@ -121,7 +125,6 @@ impl Embed { .join("\n"); // ! FIXME: allow multiple links - // ! FIXME: prevent generation if link is surrounded with < > let mut finder = LinkFinder::new(); finder.kinds(&[LinkKind::Url]); let links: Vec<_> = finder.links(&content).collect();