diff --git a/src/markdown/inline.rs b/src/markdown/inline.rs index d344385..2307cfe 100644 --- a/src/markdown/inline.rs +++ b/src/markdown/inline.rs @@ -103,9 +103,15 @@ fn styled( if let Event::Start(Tag::Link { link_type, .. }) = &event { let link_type = *link_type; let text = collect_text(events, TagEnd::Link); + // A wikilink is an entity reference and renders bold, where a + // regular link stays underlined to read as a URL. + let link_style = match link_type { + LinkType::WikiLink { .. } => style::wiki(), + _ => style::link(), + }; spans.push(Span::styled( display_text(link_type, text), - active.patch(style::link()), + active.patch(link_style), )); } if let Event::Start(Tag::Image { .. }) = &event { diff --git a/src/markdown/inline_tests.rs b/src/markdown/inline_tests.rs index 0039ac1..4e6728e 100644 --- a/src/markdown/inline_tests.rs +++ b/src/markdown/inline_tests.rs @@ -74,7 +74,7 @@ fn an_image_renders_as_its_plain_alt_text() { fn a_wikilink_reduces_to_its_last_segment() { assert_eq!( inline_text("[[rules/spells/fireball]]"), - Text::from(Line::from(vec![Span::styled("fireball", style::link())])) + Text::from(Line::from(vec![Span::styled("fireball", style::wiki())])) ); } @@ -82,7 +82,7 @@ fn a_wikilink_reduces_to_its_last_segment() { fn a_piped_wikilink_shows_its_display_text() { assert_eq!( inline_text("[[a/b|shown]]"), - Text::from(Line::from(vec![Span::styled("shown", style::link())])) + Text::from(Line::from(vec![Span::styled("shown", style::wiki())])) ); } diff --git a/src/markdown/style.rs b/src/markdown/style.rs index 91b268f..7989601 100644 --- a/src/markdown/style.rs +++ b/src/markdown/style.rs @@ -30,6 +30,12 @@ pub fn link() -> Style { .add_modifier(Modifier::UNDERLINED) } +/// A wikilink's visible text. Purple and bold, not underlined, so an +/// entity reference reads as solid rather than as a navigable URL. +pub fn wiki() -> Style { + Style::new().fg(Color::Magenta).add_modifier(Modifier::BOLD) +} + /// A heading's text. `#` and `##` underline as well as bold; `###` /// through `######` are bold alone. The `#` markers themselves never /// render. diff --git a/src/markdown/table_tests.rs b/src/markdown/table_tests.rs index 6a67b79..7247edf 100644 --- a/src/markdown/table_tests.rs +++ b/src/markdown/table_tests.rs @@ -134,7 +134,7 @@ fn a_wikilink_in_a_cell_renders_its_last_segment() { Line::from(vec![ Span::styled("│", style::border()), Span::raw(" "), - Span::styled("goblin", style::link()), + Span::styled("goblin", style::wiki()), Span::raw(" "), Span::styled("│", style::border()), ])