feat(january): ignore links between angle brackets
This commit is contained in:
@@ -100,11 +100,15 @@ impl Embed {
|
|||||||
pub async fn generate(content: String) -> Result<Vec<Embed>> {
|
pub async fn generate(content: String) -> Result<Vec<Embed>> {
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref RE_CODE: Regex = Regex::new("```(?:.|\n)+?```|`(?:.|\n)+?`").unwrap();
|
static ref RE_CODE: Regex = Regex::new("```(?:.|\n)+?```|`(?:.|\n)+?`").unwrap();
|
||||||
|
static ref RE_IGNORED: Regex = Regex::new("(<http.+>)").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore code blocks.
|
// Ignore code blocks.
|
||||||
let content = RE_CODE.replace_all(&content, "");
|
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
|
let content = content
|
||||||
// Ignore quoted lines.
|
// Ignore quoted lines.
|
||||||
.split("\n")
|
.split("\n")
|
||||||
@@ -121,7 +125,6 @@ impl Embed {
|
|||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
// ! FIXME: allow multiple links
|
// ! FIXME: allow multiple links
|
||||||
// ! FIXME: prevent generation if link is surrounded with < >
|
|
||||||
let mut finder = LinkFinder::new();
|
let mut finder = LinkFinder::new();
|
||||||
finder.kinds(&[LinkKind::Url]);
|
finder.kinds(&[LinkKind::Url]);
|
||||||
let links: Vec<_> = finder.links(&content).collect();
|
let links: Vec<_> = finder.links(&content).collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user