Something went wrong. Try again.
A 5e storytelling engine with an LLM DM
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123//! Tests for turning one paragraph's inline events into styled text.
use super::*;
/// Parses `markdown` as a single paragraph and renders its inline/// content, the way `block.rs` does for a `Paragraph` block.fn inline_text(markdown: &str) -> Text<'static> { let mut events = Events::new(markdown); assert_eq!(events.next(), Some(Event::Start(Tag::Paragraph))); text(&mut events, TagEnd::Paragraph, Style::default())}
#[test]fn strong_text_is_bold() { assert_eq!( inline_text("**bold**"), Text::from(Line::from(vec![Span::styled("bold", style::strong())])) );}
#[test]fn emphasis_text_is_italic() { assert_eq!( inline_text("*em*"), Text::from(Line::from(vec![Span::styled("em", style::emphasis())])) );}
#[test]fn nested_strong_and_emphasis_combine() { let both = style::strong().patch(style::emphasis()); assert_eq!( inline_text("**_both_**"), Text::from(Line::from(vec![Span::styled("both", both)])) );}
#[test]fn strikethrough_text_is_crossed_out() { assert_eq!( inline_text("~~gone~~"), Text::from(Line::from(vec![Span::styled( "gone", style::strikethrough() )])) );}
#[test]fn inline_code_keeps_its_literal_text() { assert_eq!( inline_text("`code`"), Text::from(Line::from(vec![Span::styled("code", style::code())])) );}
#[test]fn a_link_keeps_only_its_text() { assert_eq!( inline_text("[label](http://example.com)"), Text::from(Line::from(vec![Span::styled("label", style::link())])) );}
#[test]fn an_image_renders_as_its_plain_alt_text() { assert_eq!( inline_text(""), Text::from(Line::from(vec![Span::raw("a map of Duskmere")])) );}
#[test]fn a_wikilink_reduces_to_its_last_segment() { assert_eq!( inline_text("[[rules/spells/fireball]]"), Text::from(Line::from(vec![Span::styled("fireball", style::wiki())])) );}
#[test]fn a_piped_wikilink_shows_its_display_text() { assert_eq!( inline_text("[[a/b|shown]]"), Text::from(Line::from(vec![Span::styled("shown", style::wiki())])) );}
#[test]fn a_soft_break_becomes_a_space() { assert_eq!( inline_text("line one\nline two"), Text::from(Line::from(vec![ Span::raw("line one"), Span::raw(" "), Span::raw("line two"), ])) );}
#[test]fn a_hard_break_forces_a_new_row() { assert_eq!( inline_text("line one \nline two"), Text::from(vec![ Line::from(vec![Span::raw("line one")]), Line::from(vec![Span::raw("line two")]), ]) );}
#[test]fn inline_html_passes_through_verbatim() { assert_eq!( inline_text("some <br/> text"), Text::from(Line::from(vec![ Span::raw("some "), Span::raw("<br/>"), Span::raw(" text"), ])) );}