mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-08 19:42:12 +00:00
craft-proof it, pt — an object placeholder between the mark and a real closing quote keeps the narration exemption («Vai?\u{1}» disse lui.) (#496 review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c8cb404ab
commit
3e37fbcd7e
2 files changed
+6
-2
No files matched your search
@@ -168,7 +168,7 @@ fn ends_sentence(gap: &str, prev: &str) -> bool {
|
||||
// (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 (not after a period: `Finì. —domani` starts a sentence), or after a dialogue dash, goes on in lower case.
|
||||
if end != '.' && (rest.contains('—') || after_marks.starts_with(|c| c != '\u{1}' && CLOSING.contains(&c))) {
|
||||
if end != '.' && (rest.contains('—') || after_marks.trim_start_matches('\u{1}').starts_with(CLOSING)) {
|
||||
return false;
|
||||
}
|
||||
rest.starts_with(char::is_whitespace)
|
||||
@@ -421,6 +421,8 @@ mod tests {
|
||||
// After a period the dash opens the next line of speech: a sentence starts.
|
||||
assert!(fixes("Finì. —domani partiamo.").contains(&pair("domani", "Domani")), "{:?}", fixes("Finì. —domani partiamo."));
|
||||
assert!(fixes("Finì. — domani partiamo.").contains(&pair("domani", "Domani")), "{:?}", fixes("Finì. — domani partiamo."));
|
||||
// An inline object (`\u{1}`) before a real closing quote is skipped.
|
||||
assert!(fixes("«Vai?\u{1}» disse lui.").is_empty(), "{:?}", fixes("«Vai?\u{1}» disse lui."));
|
||||
// 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."));
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ 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.` (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)) {
|
||||
if end != '.' && after_marks.trim_start_matches('\u{1}').starts_with(CLOSING) {
|
||||
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}`) before a real closing quote is skipped.
|
||||
clean("\"Vai?\u{1}\" disse ele.");
|
||||
// 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.");
|
||||
|
||||
Reference in new issue
Block a user