diff --git a/mdast_util_to_markdown/src/state.rs b/mdast_util_to_markdown/src/state.rs index 891e82b..7a0b5c3 100644 --- a/mdast_util_to_markdown/src/state.rs +++ b/mdast_util_to_markdown/src/state.rs @@ -242,7 +242,7 @@ impl<'a> State<'a> { results.push(' '); new_info.before = " "; } else { - new_info.before = &results[results.len() - 1..]; + new_info.before = &results; } } diff --git a/mdast_util_to_markdown/tests/emphasis.rs b/mdast_util_to_markdown/tests/emphasis.rs index 44050bb..abb30c1 100644 --- a/mdast_util_to_markdown/tests/emphasis.rs +++ b/mdast_util_to_markdown/tests/emphasis.rs @@ -1,4 +1,4 @@ -use markdown::mdast::{Emphasis, Node, Text}; +use markdown::mdast::{Emphasis, Node, Paragraph, Text}; use mdast_util_to_markdown::{ to_markdown as to, to_markdown_with_options as to_md_with_opts, Options, }; @@ -47,4 +47,48 @@ fn emphasis() { "_a_\n", "should support an emphasis w/ underscores when `emphasis: \"_\"`" ); + + assert_eq!( + to(&Node::Paragraph(Paragraph { + children: vec![ + Node::Text(Text { + value: String::from("𝄞"), + position: None + }), + Node::Emphasis(Emphasis { + children: vec![Node::Text(Text { + value: String::from("a"), + position: None, + })], + position: None + }) + ], + position: None + })) + .unwrap(), + "𝄞*a*\n", + "should support non-ascii before emphasis" + ); + + assert_eq!( + to(&Node::Paragraph(Paragraph { + children: vec![ + Node::Emphasis(Emphasis { + children: vec![Node::Text(Text { + value: String::from("a"), + position: None, + })], + position: None + }), + Node::Text(Text { + value: String::from("𝄞"), + position: None + }), + ], + position: None + })) + .unwrap(), + "*a*𝄞\n", + "should support non-ascii after emphasis" + ); }