fix: markdown autolinking with images

This commit is contained in:
trisua 2025-07-20 16:41:50 -04:00
parent 46849ba66c
commit c757ddb77a
3 changed files with 7 additions and 4 deletions

2
Cargo.lock generated
View file

@ -3353,7 +3353,7 @@ dependencies = [
[[package]]
name = "tetratto-shared"
version = "12.0.3"
version = "12.0.4"
dependencies = [
"ammonia",
"chrono",

View file

@ -1,7 +1,7 @@
[package]
name = "tetratto-shared"
description = "Shared stuff for Tetratto"
version = "12.0.3"
version = "12.0.4"
edition = "2024"
authors.workspace = true
repository.workspace = true

View file

@ -173,13 +173,16 @@ pub fn parse_alignment(input: &str) -> String {
}
/// Adapted from <https://git.cypr.io/oz/autolink-rust>.
///
/// The only real change here is that autolinks require a whitespace OR end the
/// end of the pattern to match here.
pub fn autolinks(input: &str) -> String {
if input.len() == 0 {
return String::new();
}
let pattern = regex::Regex::new(
r"(?ix)\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))",
r"(?ix)\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))(\s|$)",
)
.unwrap();