Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/sentence/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,8 @@ pub(crate) fn leftover_keyval_cs_name(tail: &str) -> Option<&'static str> {
"tcbifexternal",
"tcbcontinuedraftmode",
"tcbinterruptdraftmode",
"tcbstartdraftmode",
"tcbstopdraftmode",
"tcbposterset",
"tcbfontsize",
"tcbEXTERNALIZE",
Expand Down Expand Up @@ -1767,6 +1769,8 @@ fn leftover_keyval_kind(name: &str) -> VerbKind {
| "sarg"
| "tcbcontinuedraftmode"
| "tcbinterruptdraftmode"
| "tcbstartdraftmode"
| "tcbstopdraftmode"
| "PyLTVerbatimEnv" => VerbKind::Listingcont,
"setmintedinline"
| "usemintedstyle"
Expand Down Expand Up @@ -3226,7 +3230,11 @@ fn push_segment_preserving_space(dest: &mut String, piece: &str) {
})
// `!!a` is one UAX fragment; inventing `!! a` then splitting
// `!! a` on the next pass is a wrap/SemBr cycle.
&& !dest.ends_with("!!");
&& !dest.ends_with("!!")
// After protect_inline_tokens, `.`` ` is `.` + leftover backtick
// (`dest="…."`, `piece="`\\0PHn\\0"`). Inventing `. `` ` then
// wrapping back is a SemBr cycle (ubuntu CI seed).
&& !(dest.ends_with(['.', '!', '?']) && piece.starts_with('`'));
if need_space {
dest.push(' ');
}
Expand Down Expand Up @@ -3707,6 +3715,15 @@ mod tests {
UnicodeSentenceSplitter::new().split(text)
}

#[test]
fn period_then_latex_quotes_does_not_invent_space() {
assert_eq!(
split("^{`}`.`` A0`"),
vec!["^{`}`.`` A0`".to_string()],
"must not invent space between . and ``"
);
}

#[test]
fn single_quote_bang_capital_stays_one_sentence() {
assert_eq!(
Expand Down
4 changes: 4 additions & 0 deletions tests/latex_leftover_cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ fn leftover_constructors_do_not_join() {
leftover_cmd_stays_atomic(r"\tcbposterset{colback=red}");
leftover_cmd_stays_atomic(r"\tcbcontinuedraftmode");
leftover_cmd_stays_atomic(r"\tcbinterruptdraftmode");
leftover_cmd_stays_atomic(r"\tcbstartdraftmode");
leftover_cmd_stays_atomic(r"\tcbstopdraftmode");
leftover_cmd_stays_atomic(r"\tcbfontsize{2}");
leftover_cmd_stays_atomic(r"\tcbindex");
leftover_cmd_stays_atomic(r"\tcbEXTERNALIZE");
Expand Down Expand Up @@ -410,6 +412,8 @@ fn leftover_constructors_do_not_join() {
extras_skip_no_brace("cs");
extras_skip_no_brace("OptionalLocalPitonStyle");
extras_skip_no_brace("tcbposterset");
extras_skip_no_brace("tcbstartdraftmode");
extras_skip_no_brace("tcbstopdraftmode");
extras_skip_no_brace("tcbfontsize");
extras_skip_no_brace("tcbset");
extras_skip_no_brace("tcbuselibrary");
Expand Down
12 changes: 12 additions & 0 deletions tests/sentence_delim_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ fn plaintext_latex_quoted_bang_letter_is_span_safe() {
}

#[test]
#[test]
fn plaintext_period_then_latex_quotes_is_idempotent() {
// ubuntu CI seed: first pass keeps `.`` `; second pass invents `. `` `.
let input = ".^{`}`.`` A0`";
let out = format_plain(input);
assert_eq!(
format_plain(&out),
out,
"idempotence\n in={input:?}\n out={out:?}"
);
}

fn plaintext_quoted_bang_letter_is_span_safe() {
let input = "\"!!a\"";
let out = format_plain(input);
Expand Down
Loading