mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-08 19:42:12 +00:00
craft-proof it, pt — the object placeholder is not a closing quote, so Chi era?\u{1} era Marco. still gets its capital mark (#496 review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb82e91428
commit
a8b3bb74c8
2 files changed
+8
-3
No files matched your search
@@ -165,9 +165,10 @@ fn ends_sentence(gap: &str, prev: &str) -> bool {
|
||||
}
|
||||
let after_marks = t.trim_start_matches(['.', '!', '?']);
|
||||
let rest = after_marks.trim_start_matches(CLOSING);
|
||||
// (Not the object placeholder `\u{1}`: `Chi era?\u{1} era Marco.` still starts a sentence.)
|
||||
// `«Vai?» disse lui.` and `—Vai? —disse lui.`: the narration after a quoted question or
|
||||
// exclamation, or after a dialogue dash, goes on in lower case.
|
||||
if rest.contains('—') || (end != '.' && after_marks.starts_with(CLOSING)) {
|
||||
if rest.contains('—') || (end != '.' && after_marks.starts_with(|c| c != '\u{1}' && CLOSING.contains(&c))) {
|
||||
return false;
|
||||
}
|
||||
rest.starts_with(char::is_whitespace) && rest.trim_start().chars().all(|c| matches!(c, '"' | '“' | '«' | '(' | '[' | '\'' | '—'))
|
||||
@@ -416,6 +417,8 @@ mod tests {
|
||||
assert!(fixes(t).is_empty(), "{t}: {:?}", fixes(t));
|
||||
}
|
||||
assert!(fixes("Vado a Roma? sì.").contains(&pair("sì", "Sì")), "a bare question still ends the sentence");
|
||||
// An inline object (`\u{1}`) is not a closing quote.
|
||||
assert!(fixes("Chi era?\u{1} era Marco.").contains(&pair("era", "Era")), "{:?}", fixes("Chi era?\u{1} era Marco."));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -64,8 +64,8 @@ fn ends_sentence(gap: &str, prev: &str) -> bool {
|
||||
}
|
||||
let after_marks = t.trim_start_matches(['.', '!', '?']);
|
||||
let rest = after_marks.trim_start_matches(CLOSING);
|
||||
// `"Vai?" disse ele.`: narration after a quoted question or exclamation goes on in lower case.
|
||||
if end != '.' && after_marks.starts_with(CLOSING) {
|
||||
// `"Vai?" disse ele.` (not the object placeholder `\u{1}`): narration after a quoted question or exclamation goes on in lower case.
|
||||
if end != '.' && after_marks.starts_with(|c| c != '\u{1}' && CLOSING.contains(&c)) {
|
||||
return false;
|
||||
}
|
||||
// A dialogue dash after the mark brings back the narration (`—Vai? —disse ele.`), which goes
|
||||
@@ -231,6 +231,8 @@ mod tests {
|
||||
clean("\"Vai?\" disse ele.");
|
||||
clean("«Vai!» gritou ela.");
|
||||
assert!(!messages("Vai? \"sim\".").is_empty(), "a bare question still ends the sentence");
|
||||
// An inline object (`\u{1}`) is not a closing quote.
|
||||
assert!(!messages("Quem era?\u{1} era Marco.").is_empty());
|
||||
clean("Ele disse: \"Volto amanhã\". E saiu.");
|
||||
// A list item may start in lower case.
|
||||
clean("maçãs,");
|
||||
|
||||
Reference in new issue
Block a user