|
|
|
|
@ -138,6 +138,10 @@ fn html_escape(s: &str) -> String {
|
|
|
|
|
pub fn build_synthesis_html(week: &str, date: &str, sections: &[NewsSection]) -> String {
|
|
|
|
|
let mut items_html = String::new();
|
|
|
|
|
|
|
|
|
|
if sections.is_empty() {
|
|
|
|
|
items_html.push_str("<p style=\"text-align:center;color:#6b7280;font-style:italic;padding:24px 0;\">Aucune section trouvee dans cette synthese.</p>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for section in sections {
|
|
|
|
|
items_html.push_str(&format!(
|
|
|
|
|
r#"<tr><td style="padding: 24px 0 8px 0;">
|
|
|
|
|
@ -204,6 +208,10 @@ pub fn build_synthesis_text(week: &str, date: &str, sections: &[NewsSection]) ->
|
|
|
|
|
text.push_str(&"=".repeat(50));
|
|
|
|
|
text.push('\n');
|
|
|
|
|
|
|
|
|
|
if sections.is_empty() {
|
|
|
|
|
text.push_str("\nAucune section trouvee dans cette synthese.\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for section in sections {
|
|
|
|
|
text.push_str(&format!("\n{}\n", section.title.to_uppercase()));
|
|
|
|
|
text.push_str(&"-".repeat(section.title.len()));
|
|
|
|
|
@ -353,4 +361,16 @@ mod tests {
|
|
|
|
|
assert!(text.contains("Generee le 2026-03-21"));
|
|
|
|
|
assert!(text.contains("Genere par AI Weekly Synth"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_synthesis_html_empty_sections_shows_fallback() {
|
|
|
|
|
let html = build_synthesis_html("2026-W12", "21 mars 2026", &[]);
|
|
|
|
|
assert!(html.contains("Aucune section trouvee"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_synthesis_text_empty_sections_shows_fallback() {
|
|
|
|
|
let text = build_synthesis_text("2026-W12", "21 mars 2026", &[]);
|
|
|
|
|
assert!(text.contains("Aucune section trouvee"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|