mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-31 05:47:00 -06:00
fix(engine): handle multi-byte UTF-8 characters before em-dash in dash_autoformat (#1570)
This commit is contained in:
@@ -192,7 +192,7 @@ fn dash_autoformat(s: &mut Session) -> Result<(), CmdError> {
|
||||
} else if before.ends_with(' ')
|
||||
&& let Some(i) = before.trim_end().rfind("--")
|
||||
&& i > 0
|
||||
&& before.trim_end().get(i - 1..i).is_some_and(|c| c != " ")
|
||||
&& before.trim_end()[..i].chars().next_back().is_some_and(|c| c != ' ')
|
||||
{
|
||||
let p = s.doc.para_mut(f.story, &f.path)?;
|
||||
let props = p.props_at(i).clone();
|
||||
|
||||
@@ -357,8 +357,8 @@ fn web_addresses_become_links() {
|
||||
|
||||
#[test]
|
||||
fn dashes() {
|
||||
let s = typed("a -- b and c - d and e--f ");
|
||||
assert_eq!(s.doc.plain_text(StoryRef::Body), "A – b and c – d and e—f ");
|
||||
let s = typed("a -- b and c - d and e--f and café--g ");
|
||||
assert_eq!(s.doc.plain_text(StoryRef::Body), "A – b and c – d and e—f and café—g ");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user