From 16bee243812358a79dcdcf0727a32f3c66c25511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20F=C3=B6rberg?= Date: Fri, 4 Feb 2022 11:24:09 +0100 Subject: [PATCH] Uniform rendering of links Render all links as Link in the export. Remove the special case where dead links were rendered as Emphasis instead. This makes it much easier to style links in the final output. --- src/lib.rs | 9 +++++++-- tests/testdata/expected/single-file/note.md | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cdb44f2..c74b033 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -665,10 +665,15 @@ impl<'a> Exporter<'a> { .unwrap_or_else(|| context.current_file().to_str().unwrap()), context.current_file().display(), ); + let dummy_link_tag = pulldown_cmark::Tag::Link( + pulldown_cmark::LinkType::Inline, + CowStr::from(""), + CowStr::from(""), + ); return vec![ - Event::Start(Tag::Emphasis), + Event::Start(dummy_link_tag.clone()), Event::Text(CowStr::from(reference.display())), - Event::End(Tag::Emphasis), + Event::End(dummy_link_tag.clone()), ]; } let target_file = target_file.unwrap(); diff --git a/tests/testdata/expected/single-file/note.md b/tests/testdata/expected/single-file/note.md index 5777bff..32f6149 100644 --- a/tests/testdata/expected/single-file/note.md +++ b/tests/testdata/expected/single-file/note.md @@ -1,3 +1,3 @@ -Link to *other-note*. +Link to [other-note](). -Link to *another note*. +Link to [another note]().