From 7968a4452b4c3ad51611ee7a869a0b5eaf7bfb56 Mon Sep 17 00:00:00 2001 From: Naxvog Date: Wed, 14 Oct 2026 21:26:11 +0200 Subject: [PATCH] Hyphenation: German patterns in NOTICE; pattern files skip \message Review follow-ups: the German patterns' MIT notice goes into NOTICE with the other pattern sets; the pattern reader skips other commands' arguments, so hyph-de-1996.tex's \message{} line no longer adds junk patterns and exception words; a load test for the German set; the status bar names a bare "de" tag; the docs list the languages with their own hyphenation. Co-Authored-By: Claude Opus 5.5 --- crates/proof/src/hyphen.rs | 8 ++++++++ crates/proof/src/patterns.rs | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/proof/src/hyphen.rs b/crates/proof/src/hyphen.rs index 2b262a92f..1db67eb02 100644 --- a/crates/proof/src/hyphen.rs +++ b/crates/proof/src/hyphen.rs @@ -858,6 +858,14 @@ mod tests { } } + #[test] + fn german_patterns_load() { + let p = Patterns::de(); + assert!(p.len() >= 36_709, "{}", p.len()); + // The file has no exception words, and its `\message{…}` line adds none. + assert_eq!(p.exception_count(), 0); + } + #[test] fn german_words_follow_the_german_patterns() { let de = |w: &str| hyphenate_word_in(w, &Limits::default(), ProofLang::De); diff --git a/crates/proof/src/patterns.rs b/crates/proof/src/patterns.rs index 50dd74444..08d54a947 100644 --- a/crates/proof/src/patterns.rs +++ b/crates/proof/src/patterns.rs @@ -116,13 +116,16 @@ pub struct Patterns { enum Block { Patterns, Exceptions, + /// Another command's argument (`\message{…}`), ignored. + Skip, } impl Patterns { /// Parse patterns: whitespace-separated, `%` comments to the end of the line (`#` too at the /// start of a line). A whole TeX pattern file works as is: `\patterns{…}` holds patterns and - /// `\hyphenation{…}` exception words written with their hyphens (`ni-gdy`); outside any - /// block, a token with a hyphen is an exception and anything else a pattern. + /// `\hyphenation{…}` exception words written with their hyphens (`ni-gdy`), and other + /// commands' arguments (`\message{…}`) are skipped; outside any block, a token with a hyphen + /// is an exception and anything else a pattern. pub fn parse(text: &str) -> Patterns { let mut p = Patterns::default(); let mut block = Block::Patterns; @@ -136,12 +139,17 @@ impl Patterns { let mut tok = tok; if let Some(cmd) = tok.strip_prefix('\\') { let (name, rest) = cmd.split_once('{').unwrap_or((cmd, "")); - block = if name == "hyphenation" { Block::Exceptions } else { Block::Patterns }; + block = match name { + "hyphenation" => Block::Exceptions, + "patterns" => Block::Patterns, + _ if cmd.contains('{') => Block::Skip, + _ => Block::Patterns, + }; tok = rest; } let closes = tok.ends_with('}'); let tok = tok.trim_end_matches('}'); - if !tok.is_empty() { + if !tok.is_empty() && block != Block::Skip { if block == Block::Exceptions || tok.contains('-') { p.insert_exception(tok); } else {