fix(engine): handle multi-byte UTF-8 characters before em-dash in dash_autoformat (#1570)

This commit is contained in:
divyanshu2074
2026-10-14 19:36:36 -04:00
committed by GitHub
parent 3cc0c16302
commit 8ba285cdef
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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]