From c8ea9a5fb37017170ff45ce8b35d2a056eab9a1f Mon Sep 17 00:00:00 2001 From: Brummel Date: Mon, 18 May 2026 16:34:19 +0200 Subject: [PATCH] fix: accumulate mixed-content ClaML labels (full titles) Co-Authored-By: Claude Sonnet 4.6 --- src/claml.rs | 5 ++--- tests/claml_tests.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/claml.rs b/src/claml.rs index a763a5c..db26a68 100644 --- a/src/claml.rs +++ b/src/claml.rs @@ -126,9 +126,8 @@ pub fn load(path: &str) -> Result, AppError> { Ok(Event::Text(txt)) => { if in_preferred { if let Some(m) = cur.as_mut() { - if m.description.is_empty() { - m.description = txt.unescape().unwrap_or_default().into_owned(); - } + let s = txt.unescape().unwrap_or_default(); + m.description.push_str(&s); } } } diff --git a/tests/claml_tests.rs b/tests/claml_tests.rs index 30b428f..361cf58 100644 --- a/tests/claml_tests.rs +++ b/tests/claml_tests.rs @@ -11,3 +11,14 @@ fn parses_real_claml_meta_and_titles() { assert_eq!(a01.para295, "V"); // 3-digit non-codable assert!(map.len() > 10_000); } + +#[test] +fn mixed_content_label_not_truncated() { + let map = alpha_id::claml::load("icd-claml/Klassifikationsdateien/icd10gm2026syst_claml_20250912.xml").unwrap(); + let d51 = map.get("D51").expect("D51 present"); + assert!(d51.description.contains("12"), + "mixed-content label truncated: {:?}", d51.description); + let e75 = map.get("E75.0").expect("E75.0 present"); + assert!(e75.description.starts_with("GM2"), + "mixed-content label truncated: {:?}", e75.description); +}