From b7d538b325c6a6e529c8a02bd77d3d170c7717f9 Mon Sep 17 00:00:00 2001 From: Darkhan Kubigenov Date: Tue, 15 Oct 2024 21:22:33 +0100 Subject: [PATCH] Expand more link types to inline links This is needed in order to retain old behavior after the upgrade of pulldown-cmark-to-cmark. --- Cargo.lock | 4 ++-- i18n-helpers/src/lib.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c945627..ad7e420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -966,9 +966,9 @@ checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" [[package]] name = "pulldown-cmark-to-cmark" -version = "16.0.1" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171b9687038fb417937aee4ce1d0a269897091f05be16660a1e45777533c54b9" +checksum = "41b27c0d365d60ff3e085007911d73419e5664de48155d558ebfa84d117a5109" dependencies = [ "pulldown-cmark 0.12.1", ] diff --git a/i18n-helpers/src/lib.rs b/i18n-helpers/src/lib.rs index e7c5be8..d5258d5 100644 --- a/i18n-helpers/src/lib.rs +++ b/i18n-helpers/src/lib.rs @@ -93,27 +93,27 @@ pub fn new_cmark_parser<'input, F: BrokenLinkCallback<'input>>( /// ); /// ``` pub fn extract_events<'a>(text: &'a str, state: Option>) -> Vec<(usize, Event<'a>)> { - // Expand a `[foo]` style link into `[foo][foo]`. + // Expand a `[foo]` style links into inline links like `[foo](url)` fn expand_shortcut_link(tag: Tag<'_>) -> Tag<'_> { match tag { Tag::Link { - link_type: LinkType::Shortcut, + link_type: LinkType::Shortcut | LinkType::Collapsed | LinkType::Reference, dest_url, title, id, } => Tag::Link { - link_type: LinkType::Reference, + link_type: LinkType::Inline, dest_url, title, id, }, Tag::Image { - link_type: LinkType::Shortcut, + link_type: LinkType::Shortcut | LinkType::Collapsed | LinkType::Reference, dest_url, title, id, } => Tag::Image { - link_type: LinkType::Reference, + link_type: LinkType::Inline, dest_url, title, id,