use super::escape::escape_text;
use super::layout::{document, list, paragraph, section};
use super::{Config, Info};
pub(super) fn render(name: &str, info: &Info) -> Option<String> {
let config = info
.configs
.iter()
.find(|candidate| candidate.name.as_str() == name)?;
let mut body = String::new();
body.push_str(§ion("Предупреждения", &warnings_block(config)));
body.push_str(§ion(
"Текст",
&format!("<pre>{}</pre>\n", escape_text(&config.text)),
));
Some(document(
&format!("Конфигурация {name}"),
&body,
true,
&info.platform_version,
))
}
fn warnings_block(config: &Config) -> String {
if config.warnings.is_empty() {
return paragraph("предупреждений нет");
}
let items: Vec<String> = config
.warnings
.iter()
.map(|text| escape_text(text))
.collect();
list(&items)
}