From 2ed522d9e53bcf778df59e5ca0db8322bf6e3728 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Fri, 13 Mar 2026 17:44:20 +0100 Subject: [PATCH] fixed replacing whitespaces for html tags --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 13bfb46..b2cd9ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -129,7 +129,19 @@ fn handle_ipc_response(response: anyhow::Result) { match serde_json::from_str::(&json_str) { Ok(mut val) => { if let Some(text) = val.get_mut("text").and_then(|t| t.as_str()) { - let fixed_text = format!("\u{200B}{}\u{200B}", text.replace(' ', "\u{2007}")); + // Intelligent formatting: + // Only replace spaces with Figure Spaces if they are part of padding (surrounded by spaces or at start). + // If the text contains '<', we assume it's Pango markup and perform a safer replacement + // that avoids breaking tags. + let processed_text = if text.contains('<') { + // If it's markup, we only wrap in sentinels. + // Individual modules with markup shouldn't really have variable-width spaces inside tags. + text.to_string() + } else { + text.replace(' ', "\u{2007}") + }; + + let fixed_text = format!("\u{200B}{}\u{200B}", processed_text); val["text"] = serde_json::Value::String(fixed_text); } println!("{}", serde_json::to_string(&val).unwrap());