From a9dab5cd4fd71e06d705cd1612588568502ddc07 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Fri, 14 Mar 2025 12:59:16 +1300 Subject: Support labelled internal links The latest version of the markdown library supports labelled internal links, which allows an internal link to point to a page but to display with a different name. --- src/generate_html.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/generate_html.rs b/src/generate_html.rs index eea25dc..55bd8ef 100644 --- a/src/generate_html.rs +++ b/src/generate_html.rs @@ -297,8 +297,11 @@ fn line_to_html(line: &Line, page: &Page, website: &Website) -> String { let text = &sanitize_text(text, false); html.push_str(&format!("{text}")) } Token::Math(text) => { let text = &sanitize_text(text, false); html.push_str(&format!("{text}")) } - Token::InternalLink(name) => { - let ParsedLink { path, class, label } = parse_internal_link(name, page, website); + Token::InternalLink{ label: link_label, path } => { + let ParsedLink { path, class, mut label } = parse_internal_link(path, page, website); + if !link_label.is_empty() { + label = link_label.to_string(); + } html.push_str(&format!("{label}")) } Token::ExternalLink { label, path } => { -- cgit v1.2.3-70-g09d2