html: attempt to slugify *-prefixed links

this will cause a broken link if the target heading has a CUSTOM_ID
property, but still better than always resulting in a broken link
This commit is contained in:
xfnw 2024-04-07 20:12:58 -04:00
parent 19acf572fc
commit 6358761bc0

View File

@ -57,9 +57,13 @@ impl Traverser for Handler {
Event::Enter(Container::Link(link)) => {
let path = link.path();
let path = path.trim_start_matches("file:");
let path = if let Some(p) = path.strip_prefix('*') {
let mut p = slugify!(p);
p.insert(0, '#');
p
// FIXME: breaks if linking to bare .org domain.
// hopefully most have a trailing slash?
let path = if let Some(p) = path.strip_suffix(".org") {
} else if let Some(p) = path.strip_suffix(".org") {
let mut p = p.to_string();
p.push_str(".html");
p